Advertisement
PancakePhD

Untitled

Feb 9th, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. local SOrd={"top","bottom","left","right","front","back"}
  2. local SDet,state,cLr={},nil,0,{colors.gray,colors.gray}
  3.  
  4. local backMon, leftMon, rightMon
  5.  
  6. showText = true
  7.  
  8. local function default()
  9. leftMon.setCursorPos(1,10)
  10. leftMon.setBackgroundColor(cLr[2])
  11. leftMon.clear()
  12. leftMon.write("Ready?")
  13.  
  14. rightMon.setCursorPos(1,10)
  15. rightMon.setBackgroundColor(cLr[2])
  16. rightMon.clear()
  17. rightMon.write("Ready?")
  18.  
  19. backMon.setBackgroundColor(colors.red)
  20. backMon.setCursorPos(2,2)
  21. backMon.clear()
  22. end
  23.  
  24. local function ready()
  25. leftMon.setCursorPos(1,10)
  26. leftMon.setBackgroundColor(colors.yellow)
  27. leftMon.setTextColor(colors.black)
  28. leftMon.clear()
  29. leftMon.write("Ready")
  30.  
  31. rightMon.setCursorPos(1,10)
  32. rightMon.setBackgroundColor(colors.yellow)
  33. rightMon.setTextColor(colors.black)
  34. rightMon.clear()
  35. rightMon.write("Ready")
  36.  
  37. backMon.setBackgroundColor(colors.yellow)
  38. backMon.setTextColor(colors.black)
  39. backMon.setCursorPos(2,1.5)
  40. backMon.clear()
  41. if showText then
  42. backMon.setTextScale(4)
  43. backMon.write("Ready")
  44. end
  45. end
  46.  
  47. local function go()
  48. rs.setOutput("bottom",true)
  49. sleep(8)
  50. rs.setOutput("bottom",false)
  51. sleep(8)
  52. rednet.send(HID,"reset")
  53.  
  54. leftMon.setCursorPos(1,10)
  55. leftMon.setBackgroundColor(colors.lime)
  56. leftMon.setTextColor(colors.black)
  57. leftMon.clear()
  58. leftMon.write("Go!")
  59.  
  60. rightMon.setCursorPos(1,10)
  61. rightMon.setBackgroundColor(colors.lime)
  62. rightMon.setTextColor(colors.black)
  63. rightMon.clear()
  64. rightMon.write("Go!")
  65.  
  66. backMon.setBackgroundColor(colors.lime)
  67. backMon.setCursorPos(3,1.5)
  68. backMon.clear()
  69. if showText then
  70. backMon.setTextScale(4)
  71. backMon.write("Go!")
  72. end
  73. end
  74.  
  75. local function setup()
  76. state = 0
  77.  
  78. print("ID:",os.getComputerID())
  79.  
  80. if not fs.exists("txt") then
  81. write("Host ID:")
  82. local input=read()
  83. local h=fs.open("txt","w")
  84. h.write("HID,cLr=")
  85. h.write(input)
  86. h.writeLine(",{colors.green,colors.red}")
  87. h.close()
  88. end
  89.  
  90. term.clear()
  91. term.setCursorPos(1,1)
  92.  
  93. os.loadAPI("txt")
  94. HID=txt.HID
  95. if term.isColor() then
  96. cLr=txt.cLr
  97. print("Advanced PC")
  98. else
  99. print("Normal PC")
  100. end
  101.  
  102. os.unloadAPI("txt")
  103.  
  104. print("Host ID: "..HID)
  105. print("This ID:",os.getComputerID())
  106.  
  107. for i=1,6 do
  108. if peripheral.isPresent(SOrd[i]) then
  109. SDet[i]=peripheral.getType(SOrd[i])
  110. if SDet[i]=="monitor" then
  111. if peripheral.call(SOrd[i],"isColor") then
  112. SDet[i]="monitor+"
  113. if backMon==nil then
  114. backMon=peripheral.wrap("back")
  115. end
  116.  
  117. if leftMon==nil then
  118. leftMon=peripheral.wrap("left")
  119. end
  120.  
  121. if rightMon==nil then
  122. rightMon=peripheral.wrap("right")
  123. end
  124. end
  125. elseif SDet[i]=="modem" then
  126. rednet.open(SOrd[i])
  127. state=state+1
  128. end
  129. end
  130. print(SOrd[i],"|",SDet[i])
  131. end
  132.  
  133. term.setTextColor(cLr[1])
  134. if backMon==nil or leftMon==nil or rightMon==nil then
  135. term.setTextColor(cLr[2])
  136. write("No ")
  137. end
  138.  
  139. print("Advanced Monitor Detected (Required)")
  140.  
  141. term.setTextColor(cLr[1])
  142. if state==0 then
  143. term.setTextColor(cLr[2])
  144. write("No ")
  145. end
  146.  
  147. print("Modem Detected (Required)")
  148.  
  149. if backMon==nil or leftMon==nil or rightMon==nil or state==0 then
  150. return
  151. end
  152.  
  153. print("Use monitor to continue")
  154.  
  155. state=0
  156. rednet.send(HID,"register")
  157. end
  158.  
  159. local function main()
  160.  
  161. setup()
  162.  
  163. while true do
  164. leftMon.setBackgroundColor(colors.black)
  165. leftMon.clear() leftMon.setCursorPos(1,1)
  166.  
  167. if state==0 then
  168. default()
  169. elseif state==1 then
  170. ready()
  171. end
  172.  
  173. event,x,y,z = os.pullEvent()
  174.  
  175. if event == "monitor_touch" and state < 2 then
  176. if state == 0 then
  177. rednet.send(HID,"ready")
  178. state = 1
  179. else
  180. rednet.send(HID,"unready")
  181. state = 0
  182. end
  183. elseif event == "rednet_message" then
  184. id = x
  185. message = y
  186.  
  187. print(event,"|",id,"|",message)
  188. if message == "reset" then
  189. state = 0
  190. elseif message == "go" then
  191. go()
  192. end
  193. end
  194. end
  195. end
  196.  
  197. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement