Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creeper9207 Code: CyptonOS Terminal--
- a = { ... }
- running = 1
- startMenu = 0
- os.unloadAPI("/home/termapi")
- os.loadAPI("/home/termapi")
- os.unloadAPI("/home/dbapi")
- os.loadAPI("/home/dbapi")
- function ddraw()
- x, y = term.getCursorPos()
- x2, z2 = term.getSize()
- termapi.draw()
- term.setCursorPos(x, y)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.green)
- end
- function drawMenu()
- x, y = term.getCursorPos()
- paintutils.drawFilledBox(1, 2, 7, 6, colors.lightGray)
- term.setTextColor(colors.white)
- term.setCursorPos(1, 2)
- term.write("[Desk]")
- term.setCursorPos(1, 3)
- term.write("[Files]")
- term.setCursorPos(1, 4)
- term.write("[Quest]")
- term.setCursorPos(1, 5)
- term.write("[Text]")
- term.setTextColor(colors.green)
- term.setCursorPos(x, y)
- end
- function drawRCM(x, y)
- paintutils.drawFilledBox(x, y, x+7, y+6, colors.lightGray)
- end
- shell.setDir("home")
- 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()
- end
- function verify()
- x, y = term.getSize()
- term.setTextColor(colors.green)
- term.setCursorPos(1, y)
- print("Password:")
- io.write("> ")
- termapi.draw()
- term.setBackgroundColor( colors.black )
- term.setTextColor(colors.black)
- term.setCursorPos(3, y)
- password = io.read()
- term.setTextColor(colors.green)
- if password == dbapi.getValue("/home/main", 2) then
- else
- print("Incorrect, please try again")
- verify()
- end
- end
- term.setBackgroundColor(colors.black)
- verify()
- shell.setAlias("term", "/home/term")
- function tshell()
- while true do
- termapi.draw()
- x, y = term.getSize()
- term.setTextColor(colors.green)
- term.setCursorPos(1, y)
- 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 not event == "mouse_click" then
- else
- if event then
- if button == 1 then
- if x < 7 and y == 1 then
- if startMenu == 0 then
- sleep(0.01)
- drawMenu()
- startMenu = 1
- else
- ddraw()
- startMenu = 0
- end
- elseif x < 7 and y == 2 and startMenu == 1 then
- os.reboot()
- elseif x < 7 and y == 3 and startMenu == 1 then
- os.reboot()
- elseif x < 7 and y == 4 and startMenu == 1 then
- os.reboot()
- elseif x < 7 and y == 5 and startMenu == 1 then
- os.reboot()
- end
- elseif button == 2 then
- if RCM == 0 then
- --drawRCM(x, y)
- RCM = 1
- else
- --draw()
- RCM = 0
- end
- end
- end
- end
- end
- end
- while true do
- parallel.waitForAny(tshell, buttons)
- end
Advertisement
Add Comment
Please, Sign In to add comment