Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- --Variables
- local w,h = term.getSize()
- local nOpt = 1
- local scr = 1 --Screen ID (1 = smenu 2 = App 3 = opt 4 = Util
- term.setTextColor( colors.green )
- --
- --PrintCen
- function printCentered (y,s)
- local x = math.floor((w - string.len(s)) / 2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write(s)
- end
- --Draw menu
- local function drawMenu()
- term.clear()
- term.setCursorPos(1,2)
- term.write("BasOS Ver. V1.0 Dev build")
- term.setCursorPos(1,3)
- term.write("")
- term.setCursorPos(1,18)
- shell.run("time")
- term.setCursorPos(w-11,1)
- if nOpt == 1 and scr == 1 then
- term.write("Applications")
- elseif nOpt == 2 and scr == 1 then
- term.write("Options")
- elseif nOpt == 3 and scr == 1 then
- term.write("Shutdown")
- elseif nOpt == 1 and scr == 2 then
- term.write("Games")
- elseif nOpt == 2 and scr == 2 then
- term.write("Utility")
- elseif nOpt == 3 and scr == 2 then
- term.write("Adventure")
- elseif nOpt == 4 and scr == 2 then
- term.write("Shell")
- elseif nOpt == 5 and scr == 2 then
- elseif nOpt == 1 and scr == 3 then
- term.write("Password")
- elseif nOpt == 2 and scr == 3 then
- else
- end
- end
- --GUI
- term.clear()
- local function dA()
- scr = 1
- printCentered(math.floor(h/2) - 3, "")
- printCentered(math.floor(h/2) - 2, "Start Menu")
- printCentered(math.floor(h/2) - 1, "")
- printCentered(math.floor(h/2) + 0, ((nOpt == 1) and "[-> Applications <-]") or "Applications")
- printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Options <-]") or "Options" )
- printCentered(math.floor(h/2) + 2, ((nOpt == 3) and "[-> Shut-down <-]") or "Shut-down" )
- printCentered(math.floor(h/2) + 3, ((nOpt == 4) and "[-> Reboot <-]") or "Reboot" )
- end
- local function dBA()
- scr = 21
- printCentered(math.floor(h/2) - 5, "")
- printCentered(math.floor(h/2) - 4, "")
- printCentered(math.floor(h/2) - 2, "Game Menu")
- printCentered(math.floor(h/2) - 1, "")
- printCentered(math.floor(h/2) + 0, ((nOpt == 1) and "[-> Worm <-]") or "Worm" )
- printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Minesweeper <-]") or "Minesweeper" )
- printCentered(math.floor(h/2) + 2, ((nOpt == 3) and "[-> Adventure <-]") or "Adventure" )
- printCentered(math.floor(h/2) + 3, ((nOpt == 4) and "[-> Back <-]") or "Back" )
- end
- local function dB()--Applications
- scr = 2
- printCentered(math.floor(h/2) - 5, "")
- printCentered(math.floor(h/2) - 4, "")
- printCentered(math.floor(h/2) - 2, "Applications Menu")
- printCentered(math.floor(h/2) - 1, "")
- printCentered(math.floor(h/2) + 0, ((nOpt == 2) and "[-> Games <-]") or "Games" )
- printCentered(math.floor(h/2) + 1, ((nOpt == 3) and "[-> Utility <-]") or "Utility" )
- printCentered(math.floor(h/2) + 2, ((nOpt == 4) and "[-> Shell <-]") or "Shell" )
- printCentered(math.floor(h/2) + 3, ((nOpt == 5) and "[-> Back <-]") or "Back" )
- end
- local function dBB()--Utility Menu
- scr = 22
- printCentered(math.floor(h/2) - 5, "")
- printCentered(math.floor(h/2) - 4, "")
- printCentered(math.floor(h/2) - 2, "Utility Menu")
- printCentered(math.floor(h/2) - 1, "")
- printCentered(math.floor(h/2) + 0, ((nOpt == 2) and "[-> Ink <-]") or "Ink" )
- printCentered(math.floor(h/2) + 1, ((nOpt == 3) and "[-> Disk <-]") or "Disk" )
- printCentered(math.floor(h/2) + 2, ((nOpt == 4) and "[-> LuaIDE <-]") or "LuaIDE" )
- printCentered(math.floor(h/2) + 3, ((nOpt == 5) and "[-> Back <-]") or "Back" )
- end
- local function dC()
- scr = 3
- local d = fs.open("des", "r")
- printCentered(math.floor(h/2) - 3, "")
- printCentered(math.floor(h/2) - 2, "Options Menu")
- printCentered(math.floor(h/2) - 1, "")
- printCentered(math.floor(h/2) + 0, ((nOpt == 1) and "[-> Password <-]") or "Password" )
- if d.readAll() == "t" then
- local g = 1
- printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Disable password <-]") or "Disable password" )
- else
- g = 0
- printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Enable password <-]") or "Enable password" )
- end
- printCentered(math.floor(h/2) + 2, ((nOpt == 3) and "[-> Back <-]") or "Back" )
- printCentered(math.floor(h/2) + 3, ((nOpt == 4) and " ") or " " )
- printCentered(math.floor(h/2) + 4, ((nOpt == 5) and " ") or " " )
- end
- local function Pw()
- scr = 25
- term.clear()
- local title = disk.getAudioTitle("Bottom")
- printCentered(math.floor(h/2) - 3, "Music Disc Menu")
- printCentered(math.floor(h/2) - 2, ""..disk.getAudioTitle("bottom"))
- printCentered(math.floor(h/2) + 0, ((nOpt == 1) and "[-> Play <-]") or "Play")
- printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Stop <-]") or "Stop")
- printCentered(math.floor(h/2) + 2, ((nOpt == 3) and "[-> Back <-]") or "Back")
- end
- local function PwB()
- scr = 251
- term.clear()
- printCentered(math.floor(h/2) - 3, "Floppy Disk Menu")
- printCentered(math.floor(h/2) + 0, ((nOpt == 1) and "[-> Data <-]") or "Data")
- printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Name <-]") or "Name")
- printCentered(math.floor(h/2) + 2, ((nOpt == 3) and "[-> Back <-]") or "Back")
- end
- local function PwC()
- scr = 252
- term.clear()
- printCentered(math.floor(h/2) - 3, "Name Disk")
- printCentered(math.floor(h/2) - 3, "Input Name:")
- printCentered(math.floor(h/2) + 0, "")
- local input = read()
- disk.setLabel("bottom", input)
- PwB()
- end
- local function pset()
- while true do
- scr = 252
- term.clear()
- if fs.exists("pass") == true then
- shell.run("delete pass")
- end
- printCentered(math.floor(h/2) - 3, "Input new password")
- printCentered(math.floor(h/2) - 3, " ")
- printCentered(math.floor(h/2) + 0, "")
- local input = read()
- print("Invalid password!")
- local h = fs.open("pass", "w")
- h.write(input)
- scr = 3
- dC()
- break
- end
- end
- function data()
- term.clear()
- shell.run("cd disk")
- end
- function Wtd ()
- while true do
- local e,p = os.pullEvent()
- if e == "key" then
- local key = p
- if key == 17 or key == 200 then
- term.setCursorPos(1,18)
- shell.run("time")
- if nOpt > 1 and scr == 1 then
- nOpt = nOpt - 1
- drawMenu()
- dA()
- elseif nOpt > 1 and scr == 25 then
- nOpt = nOpt - 1
- drawMenu()
- Pw()
- elseif nOpt > 1 and scr == 251 then
- nOpt = nOpt - 1
- drawMenu()
- PwB()
- elseif nOpt > 2 and scr == 2 then
- nOpt = nOpt - 1
- drawMenu()
- dB()
- elseif nOpt > 1 and scr == 3 then
- nOpt = nOpt - 1
- drawMenu()
- dC()
- elseif nOpt > 2 and scr == 22 then
- nOpt = nOpt - 1
- drawMenu()
- dBB()
- elseif nOpt > 1 and scr == 21 then
- nOpt = nOpt - 1
- drawMenu()
- dBA()
- else
- end
- elseif key == 31 or key == 208 then
- if nOpt < 4 and scr == 1 then
- nOpt = nOpt + 1
- drawMenu()
- dA()
- elseif nOpt < 5 and scr == 2 then
- nOpt = nOpt + 1
- drawMenu()
- dB()
- elseif nOpt < 5 and scr == 2 then
- nOpt = nOpt + 1
- drawMenu()
- dB()
- elseif nOpt < 2 and scr == 3 then
- nOpt = nOpt + 1
- drawMenu()
- dC()
- elseif nOpt < 3 and scr == 3 then
- nOpt = nOpt + 1
- drawMenu()
- dC()
- elseif nOpt < 5 and scr == 22 then
- nOpt = nOpt + 1
- drawMenu()
- dBB()
- elseif nOpt < 4 and scr == 21 then
- nOpt = nOpt + 1
- drawMenu()
- dBA()
- elseif nOpt < 3 and scr == 251 then
- nOpt = nOpt + 1
- drawMenu()
- PwB()
- elseif nOpt < 3 and scr == 25 then
- nOpt = nOpt + 1
- drawMenu()
- Pw()
- else
- end
- elseif key == 28 then
- if nOpt == 3 and scr == 1 then
- printCentered(math.floor(h/2) - 2, "Shutting Down...")
- sleep(1)
- printCentered(math.floor(h/2) - 2, " ")
- printCentered(math.floor(h/2) - 2, "")
- shell.run("shutdown")
- term.clear()
- end
- if nOpt == 4 and scr == 1 then
- printCentered(math.floor(h/2) - 2, "Rebooting...")
- sleep(1)
- printCentered(math.floor(h/2) - 2, " ")
- printCentered(math.floor(h/2) - 2, "")
- shell.run("reboot")
- term.clear()
- end
- if nOpt == 3 and scr == 1 then
- printCentered(math.floor(h/2) - 2, "Shutting Down...")
- sleep(1)
- printCentered(math.floor(h/2) - 1, "")
- shell.run("shutdown")
- end
- if nOpt == 1 and scr == 1 then
- scr = 2
- nOpt = 2
- drawMenu()
- dB()
- Wtd()
- end
- if nOpt == 1 and scr == 251 then
- term.setCursorPos(1,1)
- data()
- print("type 'cd ..' then 'os' to return. type 'ls' for drive content")
- shell.run("shell")
- --shell.run("ls")
- break
- end
- if nOpt == 3 and scr == 22 then
- nOpt = 1
- drawMenu()
- if disk.hasAudio("bottom") == true then
- scr = 25
- Pw()
- elseif disk.hasData("bottom") == true then
- scr = 251
- PwB()
- else
- end
- end
- if nOpt == 5 and scr == 2 then
- scr = 1
- nOpt = 1
- drawMenu()
- dA()
- Wtd()
- end
- if nOpt == 3 and scr == 2 then
- scr = 22
- nOpt = 1
- dBB()
- Wtd()
- end
- if nOpt == 3 and scr == 3 then
- scr = 1
- nOpt = 1
- dA()
- end
- if nOpt == 2 and scr == 3 then
- local d = fs.open("des", "w")
- if g == 0 then
- d.write("t")
- d.close()
- g = 1
- dC()
- printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Disable password <-]") or "Disable password" )
- elseif g == 1 then
- d.write("f")
- d.close()
- g = 0
- dC()
- printCentered(math.floor(h/2) + 1, ((nOpt == 2) and "[-> Enable password <-]") or "Enable password" )
- end
- end
- if nOpt == 1 and scr == 3 then
- pset()
- end
- if nOpt == 2 and scr == 1 then
- scr = 3
- nOpt = 1
- dC()
- end
- if nOpt == 2 and scr == 2 then
- scr = 21
- nOpt = 1
- dBA()
- Wtd()
- end
- if nOpt == 1 and scr == 21 then
- local newTabID = multishell.launch({}, "osdata/snake")
- multishell.setTitle(newTabID, "Snake")
- multishell.setFocus(newTabID)
- end
- if nOpt == 2 and scr == 22 then
- local newTabID = multishell.launch({}, "osdata/ink")
- multishell.setTitle(newTabID, "Ink")
- multishell.setFocus(newTabID)
- end
- if nOpt == 4 and scr == 22 then
- local newTabID = multishell.launch({}, "luaide")
- multishell.setTitle(newTabID, "LUAIDE")
- multishell.setFocus(newTabID)
- end
- if nOpt == 2 and scr == 21 then
- local newTabID = multishell.launch({}, "osdata/minesweep")
- multishell.setTitle(newTabID, "Mines")
- multishell.setFocus(newTabID)
- end
- if nOpt == 3 and scr == 21 then
- local newTabID = multishell.launch({}, "rom/programs/fun/adventure")
- multishell.setTitle(newTabID, "Advent")
- multishell.setFocus(newTabID)
- end
- if nOpt == 4 and scr == 2 then
- term.clear()
- term.setCursorPos(1,1)
- print("Type 'os' to return.")
- shell.run("shell")
- break
- end
- if nOpt == 5 and scr == 22 then
- nOpt = 2
- scr = 2
- drawMenu()
- dB()
- end
- if nOpt == 3 and scr == 25 then
- nOpt = 1
- scr = 22
- drawMenu()
- dBB()
- end
- if nOpt == 3 and scr == 251 then
- nOpt = 1
- scr = 22
- drawMenu()
- dBB()
- end
- if nOpt == 2 and scr == 251 then
- nOpt = 1
- scr = 252
- drawMenu()
- PwC()
- end
- if nOpt == 1 and scr == 25 then
- disk.playAudio("bottom")
- end
- if nOpt == 2 and scr == 25 then
- disk.stopAudio("bottom")
- end
- if nOpt == 4 and scr == 21 then
- scr = 2
- nOpt = 2
- drawMenu()
- dB()
- Wtd()
- end
- end
- end
- end
- end
- term.clear()
- --Display
- drawMenu()
- dA()
- Wtd()
- --cond
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement