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
- function Choice1()
- term.clear()
- term.setCursorPos(1,1)
- print("Check ID")
- sleep(2)
- term.clear()
- term.setCursorPos(1,1)
- i = disk.getID("left")
- print(i)
- print"Press Any Key To Continue"
- os.pullEvent("key")
- end
- function Choice2()
- term.clear()
- term.setCursorPos(1,1)
- if disk.isPresent("left") == true then
- print"Do you want to label this Disk"
- a = read()
- if a == "yes" then
- term.clear()
- term.setCursorPos(1,1)
- print"What should the label be?"
- label = read()
- term.clear()
- term.setCursorPos(1,1)
- print(label)
- print"This will be the label is that good?"
- c = read()
- if c == "yes" then
- disk.setLabel("left", ""..label.."")
- sleep(1)
- end
- end
- end
- end
- function Exit()
- term.clear()
- term.setCursorPos(1,1)
- onMainMenu = false
- end
- mainMenu = {
- [1] = { text = "Check ID", handler = Choice1 },
- [2] = { text = "Set Disk Label", handler = Choice2 },
- [3] = { text = "Exit", handler = Exit }
- }
- 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 == 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
- function main()
- while onMainMenu 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