Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Local Variables ]]--
- local termWidth, termHeight = termSize()
- local selectedItem = 1
- local inMainMenu = true
- local inLockdownMenu = false
- --[[ Menu Methods ]]--
- function SecretEntrance },
- print("Opening")
- rs.setOutput("back",true)
- sleep(2)
- rs.setOutput("false",false)
- os.shutdown()
- end
- function Lockdown()
- inLockdownMenu = true
- selectedItem = 1
- while inLockdownMenu do
- term.clear()
- term.setCursorPos(1,1)
- printMenu(LockdownMenu)
- event, key = os.pullEvent("key")
- onKeyPressed(key, LockdownMenu)
- end
- end
- function LockdownOn()
- print("Activating Lockdown")
- rs.setOutput("left",true)
- sleep(2)
- print("Lockdown activated")
- sleep(10)
- inLockdownMenu = false
- selectedItem = 1
- end
- function LockdownOff()
- print("Deactivating Lockdown")
- rs.setOutput("left",true)
- sleep(2)
- print("Lockdown deactivated")
- inLockdownMenu = false
- selectedItem = 1
- end
- function Config()
- inMainMenu = false
- end
- function shutdown()
- shell.run("stop")
- end
- --[[ Menu Definitions ]]--
- mainMenu = {
- [1] = { text = "Secret Entrance", handler = SecretEntrance },
- [2] = { text = "Lockdown", handler = Lockdown },
- [3] = { text = "Config", handler = Config },
- [4] = { text = "Shutdown", handler = shutdown }
- }
- LockdownMenu = {
- [1] = { text = "Activate Lockdown", handler = LockdownOn },
- [2] = { text = "Deactivate Lockdown", handler = LockdownOff }
- }
- --[[ Printing Methods ]]--
- function printMenu( menu )
- for i=1,#menu do
- if i == selectedItem then
- print(">> "..menu[i].text)
- else
- print(" "..menu[i].text)
- end
- end
- end
- --[[ Handler Methods ]]--
- function onKeyPressed( key, menu)
- if key == keys.enter then
- onItemSelected(menu)
- elseif key == keys.up then
- if selectedItem > 1 then
- selectedItem = selectedItem - 1
- end
- elseif key == keys.down then
- if selectedItem < #menu then
- selectedItem = selectedItem + 1
- end
- end
- end
- function onItemSelected( menu )
- menu[selectedItem].handler()
- end
- --[[ Main Method ]]--
- function main()
- while inMainMenu do
- term.clear()
- term.setCursorPos(1,1)
- printMenu(mainMenu)
- event, key = os.pullEvent("key")
- onKeyPressed(key,mainMenu)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement