Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --menu API V1.0
- --Variables
- local menuSelect = 3
- local menuRunning = true
- termW, termH = term.getSize()
- --Functions
- function printcenter(str,yLine)
- term.setCursorPos(termW/2-#str/2,yLine)
- print(str)
- end
- function printMenu(...)
- menuOps = {...}
- while menuRunning do
- term.clear()
- term.setCursorPos(1,1)
- for i = 2,#menuOps,1 do
- if i == menuSelect then
- term.setTextColor(tonumber(menuOps[1]))
- printcenter(menuOps[i],i+1)
- else
- term.setTextColor(1)
- printcenter(menuOps[i],i+1)
- end
- end
- event, key = os.pullEvent("key")
- if key == 200 and menuSelect > 3 then
- menuSelect = menuSelect - 1
- elseif key == 208 and menuSelect < #menuOps then
- menuSelect = menuSelect + 1
- elseif key == 28 then
- local menuRunning = false
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement