Advertisement
Kolpa

Redstone Menu

May 13th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. shell.run("clear")
  2. selected = 1
  3. options = {"this","is","a","realy","cool","way","to","test","this"}
  4. moni = peripheral.wrap("left")
  5.  
  6. function Draw()
  7. moni.clear()
  8. moni.setCursorPos(1,1)
  9. for x = 1,#options do
  10. if selected == x then
  11. mx,my = moni.getCursorPos()
  12. moni.write("["..options[x].."]")
  13. moni.setCursorPos(1,my + 1)
  14. else
  15. mx,my = moni.getCursorPos()
  16. moni.write(" "..options[x])
  17. moni.setCursorPos(1,my + 1)
  18. end
  19. end
  20. end
  21.  
  22. print("The Menu is Running on the monitor")
  23.  
  24. Draw()
  25.  
  26. while true do
  27.  
  28. repeat
  29. sleep(0)
  30. i = rs.getBundledInput("back")
  31. until i == colors.red or colors.white or colors.green
  32.  
  33. if i == colors.white and selected > 1 then
  34.     selected = selected - 1
  35.     Draw()
  36. end
  37.  
  38. if i == colors.red and selected < #options then
  39.     selected = selected + 1
  40.     Draw()
  41. end
  42.  
  43. if i == colors.green then
  44. print("somebody selected the option: "..options[selected])
  45. end
  46. repeat
  47.  
  48. bam = rs.getBundledInput("back")
  49. until bam == 0
  50.  
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement