Guest User

nexushub

a guest
Mar 25th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. local function menu(...)
  2. local sel = 1
  3. local list = {...}
  4. local offX,offY = term.getCursorPos()
  5. local curX,curY = term.getCursorPos()
  6. while true do
  7. if sel > #list then sel = 1 end
  8. if sel < 1 then sel = #list end
  9. for i = 1,#list do
  10. term.setCursorPos(offX,offY+i-1)
  11. if sel == i then
  12. print("["..list[i].."]") print(">"..list[i])
  13. else
  14. print(" "..list[i].." ")
  15. end
  16. end
  17. while true do
  18. local e,e1,e2,e3,e4,e5 = os.pullEvent()
  19. if e == "key" then
  20. if e1 == 200 then -- up key
  21. sel = sel-1
  22. break
  23. end
  24. if e1 == 208 then -- down key
  25. sel = sel+1
  26. break
  27. end
  28. if e1 == 28 then
  29. term.setCursorPos(curX,curY)
  30. return list[sel],sel
  31. end
  32. end
  33. end
  34. end
  35. end
  36.  
  37. local function book(a)
  38. local side = "back"
  39. local color = {...}
  40. redstone.setBundledOutput(side, color) -- stored space line
  41. sleep(1)
  42. redstone.setBundledOutput(side, 0) -- reset all lines to no power
  43. sleep(5) -- give the player time to use it
  44. redstone.setBundledOutput(side, colors.purple) -- send back to storage space
  45. sleep(1)
  46. redstone.setBundledOutput(side, 0)
  47. end
  48.  
  49. print("Please select a destination")
  50. while true do
  51. local selection = menu("1","2","3","4","5","6","7","8")
  52. if selection == "1" then
  53. book(colors.blue)
  54. elseif selection == "2" then
  55. book(colors.white)
  56. elseif selection == "3" then
  57. book(colors.lightgrey)
  58. elseif selection == "4" then
  59. book(colors.lightblue)
  60. elseif selection == "5" then
  61. book(colors.red)
  62. elseif selection == "6" then
  63. book(colors.pink)
  64. elseif selection == "7" then
  65. book(colors.yellow)
  66. elseif selection == "8" then
  67. book(colors.brown)
  68. end
Advertisement
Add Comment
Please, Sign In to add comment