Posted 22 February 2015 - 04:56 PM
--Creeper9207 Code: CyptonOS Terminal--
a = { ... }
startMenu = 0
os.unloadAPI("/home/termapi")
os.loadAPI("/home/termapi")
os.unloadAPI("/home/dbapi")
os.loadAPI("/home/dbapi")
function ddraw()
x, z = term.getSize()
paintutils.drawFilledBox(1, 1, x, z, colors.orange)
--paintutils.drawFilledBox(1, 1, 6, 19, colors.orange)
paintutils.drawFilledBox(1, 1, x, 1, colors.gray )
paintutils.drawFilledBox(1, 1, 7, 1, colors.lightGray )
term.setCursorPos(1, 1)
term.setTextColor( colors.white )
term.write("[Start]")
term.setBackgroundColor( colors.gray )
term.setCursorPos(z - 5, 1)
term.write("Storage Used: " .. 1048576 - fs.getFreeSpace("/") .. "/1048576")
end
function drawMenu()
paintutils.drawFilledBox(1, 2, 7, 6, colors.lightGray)
term.setCursorPos(1, 2)
term.write("[Term]")
term.setCursorPos(1, 3)
term.write("[Files]")
term.setCursorPos(1, 4)
term.write("[Quest]")
term.setCursorPos(1, 5)
term.write("[Text]")
end
function drawRCM(x, y)
paintutils.drawFilledBox(x, y, x+7, y+6, colors.lightGray)
end
shell.setDir("home") ---erroring line #35
shell.setAlias("nano", "/home/nano")
term.setCursorPos(1, 19)
if fs.exists("/.termdata/hasran") == true then
else
mainsetup = { at = "null", bt = "nil", }
ot = fs.open("/home/main", "w")
ot.write(textutils.serialize(mainsetup))
ot.flush()
ot.close()
term.setTextColor( colors.green )
term.setCursorPos(1, 19)
print("Please type a new password")
io.write("> ")
termapi.draw()
term.setBackgroundColor( colors.black )
term.setTextColor( colors.green )
term.setCursorPos(3, 19)
passwd = io.read()
dbapi.setValue("/home/main", 2, passwd)
print("Please enter a name for this computer")
io.write("> ")
termapi.draw()
term.setTextColor(colors.green)
term.setBackgroundColor( colors.black )
term.setCursorPos(3, 19)
cname = io.read()
dbapi.setValue("/home/main", 3, cname)
h = fs.open("/.termdata/hasran", "w")
h.write("do not delete")
h.flush()
h.close()
print("Do you want to launch in the desktop? Y/n")
io.write("> ")
termapi.draw()
term.setBackgroundColor(colors.black)
term.setTextColor(colors.green)
term.setCursorPos(3, 19)
p = io.read()
if p == "Y" then
l = "desktop"
elseif p == "y" then
else
l = "term"
end
dbapi.setValue("/home/config.db", 1, l)
end
function verify()
term.setTextColor(colors.green)
term.setCursorPos(1, 19)
print("Password:")
io.write("> ")
termapi.draw()
term.setBackgroundColor( colors.black )
term.setTextColor(colors.black)
term.setCursorPos(3, 19)
password = io.read()
term.setTextColor(colors.green)
if password == dbapi.getValue("/home/main", 2) then
else
print("Incorrect, please try again")
verify()
end
end
verify()
if dbapi.getValue("/home/config.db", 1) == "desktop" then
if a[1] == "term" then
else
shell.run("/home/gui/desktop")
end
else
end
shell.setAlias("term", "/home/term")
function tshell()
while true do
termapi.draw()
term.setTextColor(colors.green)
term.setCursorPos(1, 19)
term.setBackgroundColor(colors.black)
term.write(dbapi.getValue("/home/main", 3) .. " " .. shell.dir() .. "> ")
a = io.read()
tostring(a)
if string.find(a, "run") then
b = a:gsub("run ", "")
shell.run(B)/>
elseif string.find(a, "cd") then
shell.run(a)
elseif string.find(a, "dir") then
shell.run(a)
elseif string.find(a, "nano") then
shell.run(a)
elseif string.find(a, "mkdir") then
shell.run(a)
elseif string.find(a, "shutdown") then
os.shutdown()
elseif string.find(a, "reboot") then
os.reboot()
elseif string.find(a, "wget") then
shell.run(a)
elseif string.find(a, "passwd") then
shell.run(a)
elseif string.find(a, "label") then
b = a:gsub("label ", "")
dbapi.setValue("/home/main.db", 3, B)/>
print("Computer name set to " .. B)/>
os.reboot()
elseif string.find(a, "files") then
shell.run(a)
elseif string.find(a, "launch") then
if fs.exists("/home/apps/" .. a) then
shell.run("/home/apps/" .. a)
else
print("App not found, type 'Apps' for a list of apps")
end
elseif string.find(a, "desktop") then
shell.run("/home/gui/desktop")
else
shell.run(a)
--print("unknown command or program not found, type 'help' for command list")
end
end
end
function buttons()
while true do
event, button, x, y = os.pullEvent()
if event then
if button == 1 then
if x < 7 and y == 1 then
if startMenu == 0 then
drawMenu()
startMenu = 1
else
ddraw()
startMenu = 0
end
elseif x < 7 and y == 2 and startMenu == 1 then
x, y = term.getCursorPos()
paintutils.drawFilledBox(1, 1, x, y, colors.black)
shell.run("/home/term term")
elseif x < 7 and y == 3 and startMenu == 1 then
a = shell.run("/home/Files")
draw()
elseif x < 7 and y == 4 and startMenu == 1 then
a = shell.run("/home/apps/quest")
draw()
elseif x < 7 and y == 5 and startMenu == 1 then
a = shell.run("/home/luaide")
draw()
end
elseif button == 2 then
if RCM == 0 then
--drawRCM(x, y)
RCM = 1
else
--draw()
RCM = 0
end
end
end
end
end
while true do
parallel.waitForAny(tshell, buttons)
end