Advertisement
Kasama

Jackjoe Control Panel

Jul 30th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.35 KB | None | 0 0
  1. --------------------------------------------------------------------------------------------------
  2. -- ___ ___ __ ____________ __ ___ ___ __ --
  3. -- |:| /:/ /::\ |::::::::::| /::\ |::\ /::| /::\ --
  4. -- |:| /:/ /::::\ |::/-------- /::::\ |:::\ /:::| /::::\ --
  5. -- |:| /:/ /::/\::\ |::| /::/\::\ |::::\/::::| /::/\::\ --
  6. -- |:|/:/ /::/__\::\ |::\________ /::/__\::\ |::|\::/|::| /::/__\::\ --
  7. -- |:|\:\ /::/::::\::\ |::::::::::| /::/::::\::\ |::| \/ |::| /::/::::\::\ --
  8. -- |:| \:\ /::/------\::\ --------\::| /::/------\::\ |::| |::| /::/------\::\ --
  9. -- |:| \:\ /::/ \::\ /::| /::/ \::\ |::| |::| /::/ \::\ --
  10. -- |:| \:\ /::/ \::\ |::::::::::| /::/ \::\ |::| |::| /::/ \::\ --
  11. -- --- --- --- --- ------------ --- --- ---- ---- --- --- --
  12. ----------------------------------------------------------------------------------------Scripts---
  13. ----------------------------------------Spawner_Controler-----------------------------------------
  14. --------------------------------------------------------------------------------------------------
  15.  
  16. function toggleState(state)
  17. if (state == true) then
  18. state = false
  19. else
  20. state = true
  21. end
  22. return state
  23. end
  24.  
  25. function updateRedstone()
  26. if (door1State == true) then
  27. rednet.broadcast("door1","jackSpawner")
  28. else
  29. rednet.broadcast("door1c","jackSpawner")
  30. end
  31. if (door2State == true) then
  32. rednet.broadcast("door2","jackSpawner")
  33. else
  34. rednet.broadcast("door2c","jackSpawner")
  35. end
  36. if (door3State == true) then
  37. rednet.broadcast("door3","jackSpawner")
  38. else
  39. rednet.broadcast("door3c","jackSpawner")
  40. end
  41. if (door4State == true) then
  42. rednet.broadcast("door4","jackSpawner")
  43. else
  44. rednet.broadcast("door4c","jackSpawner")
  45. end
  46. if (spawn1State == true) then
  47. rednet.broadcast("spawn1","jackSpawner")
  48. else
  49. rednet.broadcast("spawn1c","jackSpawner")
  50. end
  51. if (spawn2State == true) then
  52. rednet.broadcast("spawn2","jackSpawner")
  53. else
  54. rednet.broadcast("spawn2c","jackSpawner")
  55. end
  56. end
  57.  
  58. function checkClick(x, y)
  59.  
  60. wx, wy = door1.getPosition()
  61. wsx, wsy = door1.getSize()
  62. if (intersects(x,y, wx, wy, wsx, wsy)) then
  63. return 1
  64. end
  65.  
  66. wx, wy = door2.getPosition()
  67. wsx, wsy = door2.getSize()
  68. if (intersects(x,y, wx, wy, wsx, wsy)) then
  69. return 2
  70. end
  71.  
  72. wx, wy = door3.getPosition()
  73. wsx, wsy = door3.getSize()
  74. if (intersects(x,y, wx, wy, wsx, wsy)) then
  75. return 3
  76. end
  77.  
  78. wx, wy = door4.getPosition()
  79. wsx, wsy = door4.getSize()
  80. if (intersects(x,y, wx, wy, wsx, wsy)) then
  81. return 4
  82. end
  83.  
  84. wx, wy = spawn1.getPosition()
  85. wsx, wsy = spawn1.getSize()
  86. if (intersects(x,y, wx, wy, wsx, wsy)) then
  87. return 5
  88. end
  89.  
  90. wx, wy = spawn2.getPosition()
  91. wsx, wsy = spawn2.getSize()
  92. if (intersects(x,y, wx, wy, wsx, wsy)) then
  93. return 6
  94. end
  95.  
  96. return 0
  97. end
  98.  
  99. function intersects(x, y, wx, wy, wsx, wsy)
  100.  
  101. if ((x >= wx) and (x <= (wx+wsx)) and (y >= wy) and (y <= (wy + wsy))) then
  102. return true
  103. else
  104. return false
  105. end
  106. end
  107.  
  108. function update()
  109. ------------Door 1---------------
  110. monitor.setBackgroundColor(colors.blue)
  111. monitor.setCursorPos(3,4)
  112. monitor.write("Door 1")
  113.  
  114. door1 = window.create(monitor, 10, 4, 6, 1, true)
  115. if (door1State == false) then
  116. door1.setBackgroundColor(colors.red)
  117. door1.write("Closed")
  118. else
  119. door1.setBackgroundColor(colors.green)
  120. door1.write(" Open ")
  121. end
  122. ------------Door 2---------------
  123. monitor.setBackgroundColor(colors.blue)
  124. monitor.setCursorPos(3,6)
  125. monitor.write("Door 2")
  126.  
  127.  
  128. door2 = window.create(monitor, 10, 6, 6, 1, true)
  129. if (door2State == false) then
  130. door2.setBackgroundColor(colors.red)
  131. door2.write("Closed")
  132. else
  133. door2.setBackgroundColor(colors.green)
  134. door2.write(" Open ")
  135. end
  136. ------------Door 3---------------
  137. monitor.setBackgroundColor(colors.blue)
  138. monitor.setCursorPos(3,8)
  139. monitor.write("Door 3")
  140.  
  141.  
  142. door3 = window.create(monitor, 10, 8, 6, 1, true)
  143. if (door3State == false) then
  144. door3.setBackgroundColor(colors.red)
  145. door3.write("Closed")
  146. else
  147. door3.setBackgroundColor(colors.green)
  148. door3.write(" Open ")
  149. end
  150. ------------Door 4---------------
  151. monitor.setBackgroundColor(colors.blue)
  152. monitor.setCursorPos(3,10)
  153. monitor.write("Door 4")
  154.  
  155. door4 = window.create(monitor, 10, 10, 6, 1, true)
  156. if (door4State == false) then
  157. door4.setBackgroundColor(colors.red)
  158. door4.write("Closed")
  159. else
  160. door4.setBackgroundColor(colors.green)
  161. door4.write(" Open ")
  162. end
  163. ----------Spawner 1-------------
  164. monitor.setBackgroundColor(colors.blue)
  165. monitor.setCursorPos(19,4)
  166. monitor.write("Spawner 1")
  167.  
  168. spawn1 = window.create(monitor, 19, 5, 8, 1, true)
  169. if (spawn1State == false) then
  170. spawn1.setBackgroundColor(colors.red)
  171. spawn1.write("Disabled")
  172. else
  173. spawn1.setBackgroundColor(colors.green)
  174. spawn1.write("Enabled ")
  175. end
  176. ----------Spawner 2-------------
  177. monitor.setBackgroundColor(colors.blue)
  178. monitor.setCursorPos(19,8)
  179. monitor.write("Spawner 2")
  180.  
  181. spawn2 = window.create(monitor, 19, 9, 8, 1, true)
  182. if (spawn2State == false) then
  183. spawn2.setBackgroundColor(colors.red)
  184. spawn2.write("Disabled")
  185. else
  186. spawn2.setBackgroundColor(colors.green)
  187. spawn2.write("Enabled ")
  188. end
  189. ----------------------------------
  190. end
  191.  
  192. rednet.open("back")
  193. monitor = peripheral.wrap("top")
  194. monitor.setBackgroundColor(colors.blue)
  195. monitor.setTextScale(1)
  196. monitor.clear()
  197.  
  198. monitor.setCursorPos(4, 1)
  199. monitor.write("Quad Spawner Controller")
  200.  
  201. update()
  202.  
  203. door1State = false
  204. door2State = false
  205. door3State = false
  206. door4State = false
  207. spawn1State = false
  208. spawn2State = false
  209.  
  210.  
  211.  
  212. while (true) do
  213.  
  214. update()
  215. updateRedstone()
  216. event, side, x, y = os.pullEvent("monitor_touch")
  217. click = checkClick(x, y)
  218. if (click == 1) then
  219. door1State = toggleState(door1State)
  220. elseif (click == 2) then
  221. door2State = toggleState(door2State)
  222. elseif (click == 3) then
  223. door3State = toggleState(door3State)
  224. elseif (click == 4) then
  225. door4State = toggleState(door4State)
  226. elseif (click == 5) then
  227. spawn1State = toggleState(spawn1State)
  228. elseif (click == 6) then
  229. spawn2State = toggleState(spawn2State)
  230. end
  231.  
  232. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement