Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local termWidth, termHeight = term.getSize()
- local selectedItem = 1
- local onMainMenu = true
- local onNoteMenu = false
- local onFileMenu = false
- local onAppsMenu = false
- local onGameMenu = false
- local name = " "
- function continue()
- term.setCursorPos(1,17)
- print("PRESS ANY KEY TO CONTINUEO.")
- os.pullEvent("key")
- end
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function Help()
- clear()
- shell.run("readme")
- continue()
- sleep(1)
- end
- function Notes()
- name = "Notes"
- onNoteMenu = true
- selectedItem = 1
- while onNoteMenu do
- menupos()
- printMenu(noteMenu)
- event, key = os.pullEvent("key")
- onKeyPressed(key, noteMenu)
- end
- end
- function noteChoice1()
- shell.run("OS/notepad")
- continue()
- sleep(1)
- end
- function noteChoice2()
- shell.run("OS/noteread")
- continue()
- sleep(1)
- end
- function noteChoice3()
- onNoteMenu = False
- selectedItem = 1
- end
- function Files()
- name = "Files"
- onFileMenu = true
- selectedItem = 1
- while onFileMenu do
- menupos()
- printMenu(fileMenu)
- even, key = os.pullEvent("key")
- onKeyPressed(key, fileMenu)
- end
- end
- function fileChoice1()
- clear()
- shell.run("OS/.search")
- continue()
- sleep(1)
- end
- function fileChoice2()
- clear()
- shell.run("OS/editor")
- continue()
- sleep(1)
- end
- function fileChoice3()
- clear()
- shell.run("OS/createfile")
- continue()
- sleep(1)
- end
- function fileChoice4()
- onFileMenu = False
- selectedItem = 1
- end
- function Apps()
- name = "Programs"
- onAppsMenu = true
- selectedItem = 1
- while onAppsMenu do
- menupos()
- printMenu(appsMenu)
- event, key = os.pullEvent("key")
- onKeyPressed(key, appsMenu)
- end
- end
- function appsChoice1()
- clear()
- shell.run("programs/calculator")
- continue()
- sleep(1)
- end
- function appsChoice2()
- clear()
- shell.run("dj")
- continue()
- sleep(1)
- end
- function appsChoice3()
- clear()
- shell.run("programs/tarnchat")
- continue()
- sleep(1)
- end
- function appsChoice4()
- clear()
- shell.run("OS/run")
- continue()
- sleep(1)
- end
- function appsChoice5()
- onAppsMenu = False
- selectedItem = 1
- end
- function Games()
- name = "Games"
- onGameMenu = true
- selectedItem = 1
- while onGameMenu do
- menupos()
- printMenu(gameMenu)
- event, key = os.pullEvent("key")
- onKeyPressed(key, gameMenu)
- end
- end
- function gameChoice1()
- clear()
- shell.run("programs/slots")
- continue()
- sleep(1)
- end
- function gameChoice2()
- clear()
- shell.run("adventure")
- continue()
- sleep(1)
- end
- function gameChoice3()
- clear()
- shell.run("worm")
- continue()
- sleep(1)
- end
- function gameChoice4()
- onGameMenu = False
- selectedItem = 1
- end
- function Exit()
- clear()
- if fs.exists("OS/.lock") then
- shell.run("OS/.lock")
- else
- onMainMenu = false
- end
- end
- function Shutdown()
- clear()
- os.shutdown()
- end
- function line()
- write("-------------------------------------------------")
- end
- local xpos1 = 2
- function menupos()
- term.clear()
- term.setCursorPos(1,3)
- line()
- term.setCursorPos(1,18)
- line()
- term.setCursorPos(12,1)
- print("Frozen OS Beta 2.1")
- term.setCursorPos(18,2)
- print(name)
- term.setCursorPos(1,6)
- end
- mainMenu = {
- [1] = { text = "Help", handler = Help },
- [2] = { text = "Notepad", handler = Notes },
- [3] = { text = "Files", handler = Files },
- [4] = { text = "Programs", handler = Apps },
- [5] = { text = "Games", handler = Games },
- [6] = { text = "Exit", handler = Exit },
- [7] = { text = "Shutdown", handler = Shutdown }
- }
- noteMenu = {
- [1] = { text = "Notepad", handler = noteChoice1 },
- [2] = { text = "Read Notes", handler = noteChoice2 },
- [3] = { text = "Back", handler = noteChoice3 }
- }
- fileMenu = {
- [1] = { text = "Search", handler = fileChoice1 },
- [2] = { text = "Edit", handler = fileChoice2 },
- [3] = { text = "Make Folder", handler = fileChoice3 },
- [4] = { text = "Back", handler = fileChoice4 }
- }
- appsMenu = {
- [1] = { text = "Calculator", handler = appsChoice1 },
- [2] = { text = "DJ", handler = appsChoice2 },
- [3] = { text = "TarnChat", handler = appsChoice3 },
- [4] = { text = "Run a Program", handler = appsChoice4 },
- [5] = { text = "Back", handler = appsChoice5 }
- }
- gameMenu = {
- [1] = { text = "Slots", handler = gameChoice1 },
- [2] = { text = "Adventure", handler = gameChoice2 },
- [3] = { text = "Worms", handler = gameChoice3 },
- [4] = { text = "Back", handler = gameChoice4 }
- }
- function printMenu( menu )
- for i=1,#menu do
- if i == selectedItem then
- print(" >> "..menu[i].text)
- else
- print(" "..menu[i].text)
- end
- end
- end
- function onKeyPressed( key, menu )
- if key == 28 then
- onItemSelected(menu)
- elseif key == 200 then
- if selectedItem > 1 then
- selectedItem = selectedItem - 1
- end
- elseif key == 208 then
- if selectedItem < #menu then
- selectedItem = selectedItem + 1
- end
- end
- end
- function onItemSelected( menu )
- menu[selectedItem].handler()
- end
- function main()
- while onMainMenu do
- name = " "
- menupos()
- printMenu(mainMenu)
- event, key = os.pullEvent("key")
- onKeyPressed(key,mainMenu)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement