Advertisement
Jazza

Untitled

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