Computer_Craft_Coder

Untitled

May 19th, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. --[[ menu ]]--
  2.  
  3. --[[ variables ]]--
  4.  
  5. local options={
  6. "option1",
  7. "option2",
  8. "option3"
  9. }
  10. local n=CUI(options)
  11. print(n)
  12.  
  13. --[[ functions ]]--
  14. function CUI(m)
  15. n=1
  16. l=#m
  17. while true do
  18. term.clear()
  19. term.setCursorPos(1,2)
  20. for i=1, l, 1 do
  21. if i==n then print(i, " ["..m[i].."]") else print(i, " ", m[i]) end
  22. end
  23. print("Select a number[arrow up/arrow down]")
  24. a, b= os.pullEventRaw()
  25. if a == "key" then
  26. if b==200 and n>1 then n=n-1 end
  27. if b==208 and n<=l then n=n+1 end
  28. if b==28 then break end
  29. end
  30. end
  31. term.clear() term.setCursorPos(1,1)
  32. return n
  33. end
Advertisement
Add Comment
Please, Sign In to add comment