Jazza

Untitled

Oct 27th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. --menu API V1.0
  2. --Variables
  3. local menuSelect = 1
  4. local menuRunning = true
  5. termW, termH = term.getSize()
  6.  
  7. --Functions
  8. function print.center(str,yLine)
  9.     term.setCursorPos(0,yLine)
  10.     print(str)
  11. end
  12.  
  13. function printMenu(title,...)
  14.     menuOps = {...}
  15.         while menuRunning do
  16.             clear()
  17.             print.center(title)
  18.             term.setCursorPos(2,1)
  19.             for local i=1,#menuOps,1 do
  20.                 if i=menuSelect then term.setTextColor(red) end print.center(menuOps[i],i+1)
  21.             end
  22.                 local event, local key = os.pullEvent("key")
  23.                 if  key == 200 and menuSelect > 1 then
  24.                     menuSelect = menuSelect - 1
  25.                 elseif key == 208 and menuSelect < #menuOps then
  26.                     menuSelect = menuSelect + 1
  27.                 elseif key == 28 then
  28.                     local menuRunning false
  29.                 end
  30.         end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment