Advertisement
joshgreatuk

Red Alert Server 1.0

Jul 30th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. function rasm(leftf,rightf,frontf,backf,topf,bottomf)
  2. term.clear()
  3. paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  4. paintutils.drawBox(1,1,51,19,colors.blue)
  5. term.setBackgroundColor(colors.lightBlue)
  6. term.setTextColor(colors.white)
  7. term.setCursorPos(3,3)
  8. ID = os.getComputerID()
  9. print("ID:"..tostring(ID))
  10. f1 = fs.open(leftf,"r")
  11. f2 = fs.open(rightf,"r")
  12. f3 = fs.open(frontf,"r")
  13. f4 = fs.open(backf,"r")
  14. f5 = fs.open(topf,"r")
  15. f6 = fs.open(bottomf,"r")
  16. leftc = f1.readAll()
  17. rightc = f2.readAll()
  18. frontc = f3.readAll()
  19. backc = f4.readAll()
  20. topc = f5.readAll()
  21. bottomc = f6.readAll()
  22. f1.close()
  23. f2.close()
  24. f3.close()
  25. f4.close()
  26. f5.close()
  27. f6.close()
  28. if leftc == "0" then
  29. leftc = "no"
  30. else if leftc == "1" then
  31. leftc = "yes"
  32. end
  33. end
  34. if rightc == "0" then
  35. rightc = "no"
  36. else if rightc == "1" then
  37. rightc = "yes"
  38. end
  39. end
  40. if frontc == "0" then
  41. frontc = "no"
  42. else if leftc == "1" then
  43. frontc = "yes"
  44. end
  45. end
  46. if backc == "0" then
  47. backc = "no"
  48. else if backc == "1" then
  49. backc = "yes"
  50. end
  51. end
  52. if topc == "0" then
  53. topc = "no"
  54. else if topc == "1" then
  55. topc = "yes"
  56. end
  57. end
  58. if bottomc == "0" then
  59. bottomc = "no"
  60. else if bottomc == "1" then
  61. bottomc = "yes"
  62. end
  63. end
  64. term.setCursorPos(3,5)
  65. print(leftc)
  66. term.setCursorPos(3,7)
  67. print(rightc)
  68. term.setCursorPos(3,9)
  69. print(frontc)
  70. term.setCursorPos(3,11)
  71. print(backc)
  72. term.setCursorPos(3,13)
  73. print(topc)
  74. term.setCursorPos(3,15)
  75. print(bottomc)
  76. rednet.open("top")
  77. senderId,msg = rednet.receive()
  78. rednet.close("top")
  79. if msg == "cr" then
  80. rednet.open("top")
  81. rednet.send(senderId,"y")
  82. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  83. end
  84. if msg == "lon" then
  85. f = fs.open(leftf,"w")
  86. f.write("1")
  87. f.close()
  88. redstone.setOutput("left",true)
  89. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  90. end
  91. if msg == "loff" then
  92. f = fs.open(leftf,"w")
  93. f.write("0")
  94. f.close()
  95. redstone.setOutput("left",false)
  96. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  97. end
  98. if msg == "ron" then
  99. f = fs.open(rightf,"w")
  100. f.write("1")
  101. f.close()
  102. redstone.setOutput("right",true)
  103. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  104. end
  105. if msg == "roff" then
  106. f = fs.open(rightf,"w")
  107. f.write("0")
  108. f.close()
  109. redstone.setOutput("right",false)
  110. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  111. end
  112. if msg == "fon" then
  113. f = fs.open(frontf,"w")
  114. f.write("1")
  115. f.close()
  116. redstone.setOutput("front",true)
  117. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  118. end
  119. if msg == "foff" then
  120. f = fs.open(frontf,"w")
  121. f.write("0")
  122. f.close()
  123. redstone.setOutput("front",false)
  124. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  125. end
  126. if msg == "baon" then
  127. f = fs.open(backf,"w")
  128. f.write("1")
  129. f.close()
  130. redstone.setOutput("back",true)
  131. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  132. end
  133. if msg == "baoff" then
  134. f = fs.open(backf,"w")
  135. f.write("0")
  136. f.close()
  137. redstone.setOutput("back",false)
  138. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  139. end
  140. if msg == "ton" then
  141. f = fs.open(topf,"w")
  142. f.write("1")
  143. f.close()
  144. redstone.setOutput("top",true)
  145. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  146. end
  147. if msg == "toff" then
  148. f = fs.open(topf,"w")
  149. f.write("0")
  150. f.close()
  151. redstone.setOutput("top",false)
  152. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  153. end
  154. if msg == "boon" then
  155. f = fs.open(bottomf,"w")
  156. f.write("1")
  157. f.close()
  158. redstone.setOutput("bottom",true)
  159. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  160. end
  161. if msg == "booff" then
  162. f = fs.open(bottomf,"w")
  163. f.write("0")
  164. f.close()
  165. redstone.setOutput("bottom",false)
  166. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  167. end
  168. rasm(leftf,rightf,frontf,backf,topf,bottomf)
  169. end
  170. term.clear()
  171. term.setTextColor(colors.red)
  172. term.setCursorPos(1,1)
  173. print("Starting Red Alert Server")
  174. f = fs.open("/RASD","r")
  175. rasd = f.readAll()
  176. f.close()
  177. print(rasd)
  178. rasdt = rasd.."temp"
  179. print(rasdt)
  180. fs.makeDir(rasdt)
  181. rasdf = rasd.."temp/"
  182. print(rasdf)
  183. leftf = rasdf.."left"
  184. rightf = rasdf.."right"
  185. frontf = rasdf.."front"
  186. backf = rasdf.."back"
  187. topf = rasdf.."top"
  188. bottomf = rasdf.."bottom"
  189. print(leftf)
  190. print(rightf)
  191. print(frontf)
  192. print(backf)
  193. print(topf)
  194. print(bottomf)
  195. f1 = fs.open(leftf,"w")
  196. f2 = fs.open(rightf,"w")
  197. f3 = fs.open(frontf,"w")
  198. f4 = fs.open(backf,"w")
  199. f5 = fs.open(topf,"w")
  200. f6 = fs.open(bottomf,"w")
  201. f1.write("0")
  202. f2.write("0")
  203. f3.write("0")
  204. f4.write("0")
  205. f5.write("0")
  206. f6.write("0")
  207. f1.close()
  208. f2.close()
  209. f3.close()
  210. f4.close()
  211. f5.close()
  212. f6.close()
  213. print("Successfully started Red Alert Server 1.0")
  214. sleep(3)
  215. rasm(leftf,rightf,frontf,backf,topf,bottomf)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement