Advertisement
PancakePhD

Untitled

Feb 9th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 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.  
  74. state = 0
  75. end
  76.  
  77. local function setup()
  78. state = 0
  79.  
  80. print("ID:",os.getComputerID())
  81.  
  82. if not fs.exists("txt") then
  83. write("Host ID:")
  84. local input=read()
  85. local h=fs.open("txt","w")
  86. h.write("HID,cLr=")
  87. h.write(input)
  88. h.writeLine(",{colors.green,colors.red}")
  89. h.close()
  90. end
  91.  
  92. term.clear()
  93. term.setCursorPos(1,1)
  94.  
  95. os.loadAPI("txt")
  96. HID=txt.HID
  97. if term.isColor() then
  98. cLr=txt.cLr
  99. print("Advanced PC")
  100. else
  101. print("Normal PC")
  102. end
  103.  
  104. os.unloadAPI("txt")
  105.  
  106. print("Host ID: "..HID)
  107. print("This ID:",os.getComputerID())
  108.  
  109. for i=1,6 do
  110. if peripheral.isPresent(SOrd[i]) then
  111. SDet[i]=peripheral.getType(SOrd[i])
  112. if SDet[i]=="monitor" then
  113. if peripheral.call(SOrd[i],"isColor") then
  114. SDet[i]="monitor+"
  115. if backMon==nil then
  116. backMon=peripheral.wrap("back")
  117. end
  118.  
  119. if leftMon==nil then
  120. leftMon=peripheral.wrap("left")
  121. end
  122.  
  123. if rightMon==nil then
  124. rightMon=peripheral.wrap("right")
  125. end
  126. end
  127. elseif SDet[i]=="modem" then
  128. rednet.open(SOrd[i])
  129. state=state+1
  130. end
  131. end
  132. print(SOrd[i],"|",SDet[i])
  133. end
  134.  
  135. term.setTextColor(cLr[1])
  136. if backMon==nil or leftMon==nil or rightMon==nil then
  137. term.setTextColor(cLr[2])
  138. write("No ")
  139. end
  140.  
  141. print("Advanced Monitor Detected (Required)")
  142.  
  143. term.setTextColor(cLr[1])
  144. if state==0 then
  145. term.setTextColor(cLr[2])
  146. write("No ")
  147. end
  148.  
  149. print("Modem Detected (Required)")
  150.  
  151. if backMon==nil or leftMon==nil or rightMon==nil or state==0 then
  152. return
  153. end
  154.  
  155. print("Use monitor to continue")
  156.  
  157. state=0
  158. rednet.send(HID,"register")
  159. end
  160.  
  161. local function main()
  162.  
  163. setup()
  164.  
  165. while true do
  166. leftMon.setBackgroundColor(colors.black)
  167. leftMon.clear() leftMon.setCursorPos(1,1)
  168.  
  169. if state==0 then
  170. default()
  171. elseif state==1 then
  172. ready()
  173. end
  174.  
  175. event,x,y,z = os.pullEvent()
  176.  
  177. if event == "rednet_message" then
  178. id = x
  179. message = y
  180.  
  181. print(event,"|",id,"|",message)
  182. if message == "go" then
  183. go()
  184. end
  185. elseif event == "monitor_touch" and state < 2 then
  186. if state == 0 then
  187. rednet.send(HID,"ready")
  188. state = 1
  189. else
  190. rednet.send(HID,"unready")
  191. state = 0
  192. end
  193. end
  194. end
  195. end
  196.  
  197. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement