Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local termWidth, termHeight = term.getSize()
- local selectedItem = 10
- local onMainMenu = true
- function Choice1()
- term.clear()
- print("CHOICE 1")
- sleep(1)
- end
- function Choice2()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice3()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice4()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice5()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice6()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice7()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice8()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice9()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice10()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice11()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice12()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice13()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice14()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice15()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice16()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice17()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice18()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice19()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Choice20()
- term.clear()
- print("CHOICE 2")
- sleep(1)
- end
- function Exit()
- onMainMenu = false
- end
- mainMenu = {
- [1] = { text = "Choice 1", handler = Choice1 },
- [2] = { text = "Choice 2", handler = Choice2 },
- [3] = { text = "Exit", handler = Exit },
- [4] = { text = "Choice 3", handler = Choice3 },
- [5] = { text = "Choice 4", handler = Choice4 },
- [6] = { text = "Choice 5", handler = Choice5 },
- [7] = { text = "Choice 6", handler = Choice6 },
- [8] = { text = "Choice 7", handler = Choice7 },
- [9] = { text = "Choice 8", handler = Choice8 },
- [10] = { text = "Choice 9", handler = Choice9 },
- [11] = { text = "Choice 10", handler = Choice10 },
- [12] = { text = "Choice 11", handler = Choice11 },
- [13] = { text = "Choice 12", handler = Choice12 },
- [14] = { text = "Choice 13", handler = Choice13 },
- [15] = { text = "Choice 14", handler = Choice14 },
- [16] = { text = "Choice 15", handler = Choice15 },
- [17] = { text = "Choice 16", handler = Choice16 },
- [18] = { text = "Choice 17", handler = Choice17 },
- [19] = { text = "Choice 18", handler = Choice18 },
- [20] = { text = "Choice 19", handler = Choice19 },
- [21] = { text = "Choice 20", handler = Choice20 },
- }
- function printMenu( menu )
- for i=1,#menu do
- if i == selectedItem then
- term.clear()
- term.setCursorPos(1,1)
- 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
- 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