Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Programs File
- Written by TheShadow989
- ]]--
- os.pullEvent = os.pullEventRaw
- local verNumber = "Alpha 1.24"
- local nOption = 1
- rRead = fs.open("xos/.usertable", "r")
- users = textutils.unserialize(rRead.readAll())
- rRead.close()
- cu = tonumber(users[1])
- cs = tonumber(users[cu+1])
- cp = tonumber(users[cu+2])
- local w,h = term.getSize()
- local function drawMenu()
- local time = os.time()
- local formattedTime = textutils.formatTime(time, false)
- term.clear()
- term.setCursorPos(1,1)
- term.write("Logged in as: ")
- term.setTextColor( colors.red )
- term.write(""..users[cu].."")
- term.setTextColor( colors.white )
- term.setCursorPos(1,2)
- write(formattedTime)
- term.setCursorPos(1,19)
- term.write("xOS "..verNumber.." by TheShadow989")
- term.setCursorPos(w-11,1)
- if nOption == 1 then
- term.write("Browser")
- elseif nOption == 2 then
- term.write("Unknown")
- elseif nOption == 3 then
- term.write("Unknown")
- elseif nOption == 4 then
- term.write("Unknown")
- elseif nOption == 5 then
- term.write("Page 2")
- elseif nOption == 6 then
- term.write("Back")
- else
- end
- end
- function printCentered(y,s)
- local x = math.floor((w - string.len(s)) / 2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write( s )
- end
- term.clear()
- term.setCursorPos(1,19)
- term.write("xOS "..verNumber.." by TheShadow989")
- local function drawFrontend()
- printCentered( math.floor(h/2) - 4, "")
- printCentered( math.floor(h/2) - 3, "Programs [Page 1 ]" )
- printCentered( math.floor(h/2) - 2, "")
- printCentered( math.floor(h/2) - 1, ((nOption == 1) and "[ Browser ]") or " Browser " )
- printCentered( math.floor(h/2) + 0, ((nOption == 2) and "[ Unknown ]") or " Unknown " )
- printCentered( math.floor(h/2) + 1, ((nOption == 3) and "[ Unknown ]") or " Unknown " )
- printCentered( math.floor(h/2) + 2, ((nOption == 4) and "[ Unknown ]") or " Unknown " )
- printCentered( math.floor(h/2) + 3, "")
- printCentered( math.floor(h/2) + 4, ((nOption == 5) and "[ Page 2 ]") or " Page 2 " )
- printCentered( math.floor(h/2) + 5, ((nOption == 6) and "[ Back ]") or " Back " )
- end
- drawMenu()
- drawFrontend()
- while true do
- local e,p = os.pullEvent()
- if e == "key" then
- local key = p
- if key == 17 or key == 200 then
- if nOption > 1 then
- nOption = nOption - 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 31 or key == 208 then
- if nOption < 6 then
- nOption = nOption + 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 28 then
- break
- end
- end
- end
- term.clear()
- if nOption == 1 then
- shell.run("xos/.browser")
- elseif nOption == 2 then
- shell.run("xos/.reactor")
- elseif nOption == 3 then
- os.shutdown()
- elseif nOption == 4 then
- shell.run("xos/.UninstallDialog")
- elseif nOption == 5 then
- shell.run("xos/.programs2")
- elseif nOption == 6 then
- shell.run("back")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement