Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --menu API V1.0
- --Variables
- local menuSelect = 1
- local menuRunning = true
- termW, termH = term.getSize()
- --Functions
- function print.center(str,yLine)
- term.setCursorPos(0,yLine)
- print(str)
- end
- function printMenu(title,...)
- menuOps = {...}
- while menuRunning do
- clear()
- print.center(title)
- term.setCursorPos(2,1)
- for local i=1,#menuOps,1 do
- if i=menuSelect then term.setTextColor(red) end print.center(menuOps[i],i+1)
- end
- local event, local key = os.pullEvent("key")
- if key == 200 and menuSelect > 1 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