Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function one()
- print("Hello")
- end
- function two()
- print("Hey")
- end
- function three()
- print("Hi")
- end
- local menuOptions = {"1", "2", "3"}
- local termX, termY = term.getSize()
- local selected = 1
- function centerText(text, termY)
- term.setCursorPos(termX/2-#text/2,termY)
- term.write(text)
- return true
- end
- function start()
- while true do
- term.clear()
- for i,v in ipairs(menuOptions) do
- if i == selected then
- centerText("[ "..v.."] ", i)
- else
- centerText(v,i)
- end
- end
- local id, key = os.pullEvent()
- if key == 208 and selected < #menuOptions then
- selected = selected + 1
- elseif key == 200 and selected > 1 then
- selected = selected - 1
- elseif key == 28 then
- return selected
- end
- end
- end
- x = start()
- print()
- if selected == 1 then
- one()
- end
- if selected == 2 then
- two()
- end
- if selected == 3 then
- three()
- end
Advertisement
Add Comment
Please, Sign In to add comment