Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. --Hardware Variables--
  2. local m1 = peripheral.wrap("monitor_25")
  3. local m2 = peripheral.wrap("monitor_3")
  4. local m3 = peripheral.wrap("monitor_23")
  5. local m4 = peripheral.wrap("monitor_22")
  6. local r1 = peripheral.wrap("BigReactors-Reactor_2")
  7. local t1 = peripheral.wrap("BigReactors-Turbine_1")
  8. local t2 = peripheral.wrap("BigReactors-Turbine_0")
  9.  
  10. --Control Button Toggle --
  11. function btn(y,state)
  12.  
  13. if state == "on" then
  14. m1.setCursorPos(18,y)
  15. m1.setBackgroundColor(colors.green)
  16. m1.write(" ON ")
  17. m1.setCursorPos(25,y)
  18. m1.setBackgroundColor(colors.gray)
  19. m1.write(" OFF ")
  20.  
  21. m1.setCursorPos(30,y)
  22. elseif state == "off" then
  23. m1.setCursorPos(18,y)
  24. m1.setBackgroundColor(colors.gray)
  25. m1.write(" ON ")
  26. m1.setCursorPos(25,y)
  27. m1.setBackgroundColor(colors.red)
  28. m1.write(" OFF ")
  29.  
  30. m1.setCursorPos(30,y)
  31. end
  32.  
  33. end
  34.  
  35. --Start Program--
  36.  
  37. m1.clear()
  38.  
  39. --Reactor
  40. r1.setActive(true)
  41. m1.setCursorPos(1,1)
  42. m1.setBackgroundColor(colors.black)
  43. m1.write("Reactor")
  44. btn(1,"on")
  45.  
  46. --Turbine 1
  47. t1.setActive(true)
  48. m1.setCursorPos(1,2)
  49. m1.setBackgroundColor(colors.black)
  50. m1.write("Turbine 1")
  51. btn(2,"on")
  52.  
  53. --Turbine 2
  54. t2.setActive(true)
  55. m1.setCursorPos(1,3)
  56. m1.setBackgroundColor(colors.black)
  57. m1.write("Turbine 2")
  58. btn(3,"on")
  59.  
  60. --Blast door
  61. redstone.setOutput("top",false)
  62. m1.setCursorPos(1,5)
  63. m1.setBackgroundColor(colors.black)
  64. m1.write("Blast Door")
  65. btn(5,"off")
  66.  
  67. m1.setCursorPos(1,1)
  68. m1.setBackgroundColor(colors.black)
  69.  
  70. while true do
  71.  
  72. --Button Press--
  73. os.startTimer(0.5)
  74.  
  75. while true do
  76. local evt = {os.pullEvent()}
  77. if evt[1]=="timer" then
  78. break
  79. elseif evt[1]=="monitor_touch" then
  80. local x,y = evt[3],evt[4]
  81. if evt[2] == "monitor_25" then
  82.  
  83. --ON--
  84. if x>=18 and x<=22 then
  85. btn(y,"on")
  86.  
  87. if y==1 then
  88. r1.setActive(true)
  89. elseif y==2 then
  90. t1.setActive(true)
  91. elseif y==3 then
  92. t2.setActive(true)
  93. elseif y==4 then
  94. --blank line
  95. elseif y==5 then
  96. redstone.setOutput("top",true)
  97. end
  98.  
  99. --OFF--
  100. elseif x>25 and x<=30 then
  101. btn(y,"off")
  102.  
  103. if y==1 then
  104. r1.setActive(false)
  105. elseif y==2 then
  106. t1.setActive(false)
  107. elseif y==3 then
  108. t2.setActive(false)
  109. elseif y==4 then
  110. --blank line
  111. elseif y==5 then
  112. redstone.setOutput("top",false)
  113. end
  114. end
  115. end
  116. end
  117. end
  118. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement