Advertisement
Guest User

elevator.lua

a guest
Oct 1st, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. os.loadAPI("button")
  2. m = peripheral.wrap("back")
  3. wr = peripheral.wrap("right")
  4. local switches={}
  5. redstone.setBundledOutput("bottom",0)
  6.  
  7. m.setTextScale(0.5)
  8. m.clear()
  9.  
  10. --Design--
  11. term.setCursorPos(1,5)
  12. print("-------")
  13. term.setCursorPos(8,1)
  14. print("|")
  15. term.setCursorPos(8,2)
  16. print("|")
  17. term.setCursorPos(8,3)
  18. print("|")
  19. term.setCursorPos(8,4)
  20. print("|")
  21. term.setCursorPos(8,5)
  22. print("|")
  23. term.setCursorPos(8,6)
  24. print("|")
  25. term.setCursorPos(8,7)
  26. print("|")
  27. term.setCursorPos(8,8)
  28. print("|")
  29. term.setCursorPos(8,9)
  30. print("|")
  31.  
  32.  
  33. --Buttons--
  34. function mainTable()
  35. button.clearTable()
  36. button.setTable("UP" , up , 2,6,2,3)
  37. button.setTable("DOWN", down, 2,6,7,8)
  38. button.setTable("Haus", haus, 10,14,2,2)
  39. --button.setTable("1.UG", 1ug , 10,14,4,4)
  40. --button.setTable("2.UG", 2ug , 10,14,6,6)
  41. --button.setTable("3.UG", 3ug , 10,14,8,8)
  42. button.screen()
  43. end
  44.  
  45. --Signals--
  46.  
  47. function switch(name, colr)
  48. if switches[name] then
  49. redstone.setBundledOutput("bottom", redstone.getBundledOutput("bottom") - colr)
  50. else
  51. redstone.setBundledOutput("bottom", redstone.getBundledOutput("bottom") + colr)
  52. end
  53. switches[name] = not switches[name]
  54. end
  55.  
  56. function up()
  57. switch("UP", colors.orange)
  58. button.toggleButton("UP")
  59. sleep(2)
  60. switch("UP", colors.orange)
  61. button.toggleButton("UP")
  62. end
  63.  
  64. function down()
  65. switch("DOWN", colors.black)
  66. button.toggleButton("DOWN")
  67. sleep(2)
  68. switch("DOWN", colors.black)
  69. button.toggleButton("DOWN")
  70. end
  71.  
  72. function haus()
  73. switch("Haus", colors.pink)
  74. button.toggleButton("Haus")
  75. sleep(2)
  76. switch("Haus", colors.pink)
  77. button.toggleButton("Haus")
  78. end
  79.  
  80. function getclick()
  81. event,side,x,y = os.pullEvent("monitor_touch")
  82. button.checkxy(x,y)
  83. end
  84.  
  85. while true do
  86. mainTable()
  87. getclick()
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement