Advertisement
loepie

ReactorControlWireless

Mar 15th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. os.loadAPI("button")
  2. os.loadAPI("/rom/apis/rednet")
  3. m = peripheral.wrap("monitor_0")
  4. p = peripheral.wrap("back")
  5. os.loadAPI("/rom/apis/rednet")
  6. rednet.open("bottom")
  7. m.clear()
  8.  
  9. xm1 = 0 --Counter for receiving no message from computer RC(x)
  10. xm2 = 0 --Counter for receiving no message from computer RC(x)
  11. xm3 = 0 --Counter for receiving no message from computer RC(x)
  12. xm4 = 0 --Counter for receiving no message from computer RC(x)
  13. xm5 = 0 --Counter for receiving no message from computer RC(x)
  14. xm6 = 0 --Counter for receiving no message from computer RC(x)
  15.  
  16. local rfp1 = "reactor_fluid_port_15"    -- Location Reactor Fluid Port
  17. local rfp2 = "reactor_fluid_port_16"        -- Location Reactor Fluid Port
  18. local rfp3 = "reactor_fluid_port_17"        -- Location Reactor Fluid Port
  19. local rfp4 = "reactor_fluid_port_18"    -- Location Reactor Fluid Port
  20. local rfp5 = "reactor_fluid_port_19"    -- Location Reactor Fluid Port
  21. local rfp6 = "reactor_fluid_port_20"    -- Location Reactor Fluid Port
  22. local nr1 = "nuclear_reactor_7"     -- Location Reactor Access Hatch
  23. local nr2 = "nuclear_reactor_8"     -- Location Reactor Access Hatch
  24. local nr3 = "nuclear_reactor_9"     -- Location Reactor Access Hatch
  25. local nr4 = "nuclear_reactor_10"        -- Location Reactor Access Hatch
  26. local nr5 = "nuclear_reactor_11"        -- Location Reactor Access Hatch
  27. local nr6 = "nuclear_reactor_12"        -- Location Reactor Access Hatch
  28.  
  29. --MFSU's
  30. --Groep 1
  31. local mfsu1 = nil       -- Location R1A
  32. local mfsu2 = nil       -- Location R1B
  33. local mfsu3 = nil       -- Location R2A
  34. local mfsu4 = nil       -- Location R2B
  35. local mfsu5 = nil       -- Location MFSU Group 1
  36. local mfsug1_6 = nil
  37. local mfsug1_7 = nil
  38. local mfsug1_8 = nil
  39. local mfsug1_9 = nil
  40. local mfsug1_10 = nil
  41. --Groep 2
  42. local mfsu6 = nil       -- Location R1A
  43. local mfsu7 = nil       -- Location R1B
  44. local mfsu8 = nil       -- Location R2A
  45. local mfsu9 = nil       -- Location R2B
  46. local mfsu10 = nil      -- Location MFSU Group 2
  47. local mfsug2_6 = nil
  48. local mfsug2_7 = nil
  49. local mfsug2_8 = nil
  50. local mfsug2_9 = nil
  51. local mfsug2_10 = nil
  52. --Groep 3
  53. local mfsu11 = nil  -- Location R1A
  54. local mfsu12 = nil  -- Location R1B
  55. local mfsu13 = nil  -- Location R2A
  56. local mfsu14 = nil  -- Location R2B
  57. local mfsu15 = nil  -- Location MFSU Group 3
  58. local mfsug3_6 = nil
  59. local mfsug3_7 = nil
  60. local mfsug3_8 = nil
  61. local mfsug3_9 = nil
  62. local mfsug3_10 = nil
  63.  
  64. --MFSU's
  65. --Groep 1
  66. mfsu_1 = "mfsu_12"  -- Location MFSU1
  67. mfsu_2 = "mfsu_10"  -- Location MFSU2
  68. mfsu_3 = "mfsu_11"  -- Location MFSU3
  69. mfsu_4 = "mfsu_9"   -- Location MFSU4
  70. mfsu_5 = "mfsu_1"   -- Location MFSU5
  71. v_mfsug1_6 = "mfsu_21"  -- Location MFSU5
  72. v_mfsug1_7 = "mfsu_22"  -- Location MFSU5
  73. v_mfsug1_8 = "mfsu_23"  -- Location MFSU5
  74. v_mfsug1_9 = "mfsu_24"  -- Location MFSU5
  75. v_mfsug1_10 = "mfsu_33" -- Location MFSU5
  76.  
  77. --Groep 2
  78. mfsu_6 = "mfsu_15"  -- Location MFSU6
  79. mfsu_7 = "mfsu_13"  -- Location MFSU7
  80. mfsu_8 = "mfsu_16"  -- Location MFSU8
  81. mfsu_9 = "mfsu_14"  -- Location MFSU9
  82. mfsu_10 = "mfsu_4"  -- Location MFSU4
  83. v_mfsug2_6 = "mfsu_25"  -- Location MFSU5
  84. v_mfsug2_7 = "mfsu_26"  -- Location MFSU5
  85. v_mfsug2_8 = "mfsu_27"  -- Location MFSU5
  86. v_mfsug2_9 = "mfsu_28"  -- Location MFSU5
  87. v_mfsug2_10 = "mfsu_34" -- Location MFSU5
  88.  
  89. --Groep 3
  90. mfsu_11 = "mfsu_17" -- Location MFSU5
  91. mfsu_12 = "mfsu_19" -- Location MFSU6
  92. mfsu_13 = "mfsu_18" -- Location MFSU7
  93. mfsu_14 = "mfsu_20" -- Location MFSU8
  94. mfsu_15 = "mfsu_7"  -- Location MFSU9
  95. v_mfsug3_6 = "mfsu_29"  -- Location MFSU5
  96. v_mfsug3_7 = "mfsu_30"  -- Location MFSU5
  97. v_mfsug3_8 = "mfsu_31"  -- Location MFSU5
  98. v_mfsug3_9 = "mfsu_32"  -- Location MFSU5
  99. v_mfsug3_10 = "mfsu_35" -- Location MFSU5
  100.  
  101. local IsActive = "PlaceHolder" 
  102.  
  103. --computers that can send wireless signals
  104. local rc1 = rednet.lookup("rctrl","rc1")
  105.  
  106. if tonumber(rc1) == nil then
  107.     sleep(5)
  108.     local rc1 = rednet.lookup("rctrl","rc1")
  109.     if tonumber(rc1) == nil then
  110.         rc1 = 0
  111.     end
  112. end
  113. local rc2 = rednet.lookup("rctrl","rc2")
  114. if tonumber(rc2) == nil then
  115.     sleep(5)
  116.     local rc2 = rednet.lookup("rctrl","rc2")
  117.     if tonumber(rc2) == nil then
  118.         rc2 = 0
  119.     end
  120. end
  121. local rc3 = rednet.lookup("rctrl","rc3")
  122. if tonumber(rc3) == nil then
  123.     sleep(5)
  124.     local rc3 = rednet.lookup("rctrl","rc3")
  125.     if tonumber(rc3) == nil then
  126.         rc3 = 0
  127.     end
  128. end
  129. local rc4 = rednet.lookup("rctrl","rc4")
  130. if tonumber(rc4) == nil then
  131.     sleep(5)
  132.     local rc4 = rednet.lookup("rctrl","rc4")
  133.     if tonumber(rc4) == nil then
  134.         rc4 = 0
  135.     end
  136. end
  137. local rc5 = rednet.lookup("rctrl","rc5")
  138. if tonumber(rc5) == nil then
  139.     sleep(5)
  140.     local rc5 = rednet.lookup("rctrl","rc5")
  141.     if tonumber(rc5) == nil then
  142.         rc5 = 0
  143.     end
  144. end
  145. local rc6 = rednet.lookup("rctrl","rc6")
  146. if tonumber(rc6) == nil then
  147.     sleep(5)
  148.     local rc6 = rednet.lookup("rctrl","rc6")
  149.     if tonumber(rc6) == nil then
  150.         rc6 = 0
  151.     end
  152. end
  153.  
  154. --computers that are under the reactors
  155. local rs1 = rednet.lookup("rctrl","rs1")
  156. local rs2 = rednet.lookup("rctrl","rs2")
  157. local rs3 = rednet.lookup("rctrl","rs3")
  158. local rs4 = rednet.lookup("rctrl","rs4")
  159. local rs5 = rednet.lookup("rctrl","rs5")
  160. local rs6 = rednet.lookup("rctrl","rs6")
  161.  
  162. R1OnOff = "Off"
  163. R2OnOff = "Off"
  164. R3OnOff = "Off"
  165. R4OnOff = "Off"
  166. R5OnOff = "Off"
  167. R6OnOff = "Off"
  168.  
  169. mfsu1 = peripheral.wrap(mfsu_1)
  170. mfsu2 = peripheral.wrap(mfsu_2)
  171. mfsu3 = peripheral.wrap(mfsu_3)
  172. mfsu4 = peripheral.wrap(mfsu_4)
  173. mfsu5 = peripheral.wrap(mfsu_5)
  174. mfsu6 = peripheral.wrap(mfsu_6)
  175. mfsu7 = peripheral.wrap(mfsu_7)
  176. mfsu8 = peripheral.wrap(mfsu_8)
  177. mfsu9 = peripheral.wrap(mfsu_9)
  178. mfsug1_6 = peripheral.wrap(v_mfsug1_6)
  179. mfsug1_7 = peripheral.wrap(v_mfsug1_7)
  180. mfsug1_8 = peripheral.wrap(v_mfsug1_8)
  181. mfsug1_9 = peripheral.wrap(v_mfsug1_9)
  182. mfsug1_10 = peripheral.wrap(v_mfsug1_10)
  183. mfsug2_6 = peripheral.wrap(v_mfsug2_6)
  184. mfsug2_7 = peripheral.wrap(v_mfsug2_7)
  185. mfsug2_8 = peripheral.wrap(v_mfsug2_8)
  186. mfsug2_9 = peripheral.wrap(v_mfsug2_9)
  187. mfsug2_10 = peripheral.wrap(v_mfsug2_10)
  188. mfsug3_6 = peripheral.wrap(v_mfsug3_6)
  189. mfsug3_7 = peripheral.wrap(v_mfsug3_7)
  190. mfsug3_8 = peripheral.wrap(v_mfsug3_8)
  191. mfsug3_9 = peripheral.wrap(v_mfsug3_9)
  192. mfsug3_10 = peripheral.wrap(v_mfsug3_10)
  193.  
  194.  
  195. local rg1a = colors.white
  196. local rg1b = colors.orange
  197. local rg2a = colors.magenta
  198. local rg2b = colors.lightBlue
  199. local rg3a = colors.yellow
  200. local rg3b = colors.lime
  201. local rg4a = colors.pink
  202. local rg4b = colors.gray
  203. local rg5a = colors.lightGray
  204. local rg5b = colors.cyan
  205. local rg6a = colors.purple
  206. local rg6b = colors.blue
  207.  
  208. function rgCheck()
  209. -- Check Reactor Generators
  210.     senderIdLrgA = {}
  211.     vMLrgA = {}
  212.     vPLrgA = {}
  213.     senderIdLrgB = {}
  214.     vMLrgB = {}
  215.     vPLrgB = {}
  216.  
  217.     m.setCursorPos(42,1) m.write("--Power Generators--")
  218.     while true do
  219.         sleep(0.5)
  220.  
  221.         cnt = 0
  222.         for cnt = 1,6 do
  223.             senderIdLrgA[cnt], vMLrgA[cnt], vPLrgA[cnt] = rednet.receive("RG"..cnt.."A",6)
  224.             print(tostring(senderIdLrgA[cnt])..":"..tostring(vMLrgA[cnt])..":"..tostring(vPLrgA[cnt]).." RG"..cnt.."A")
  225.         end
  226.         cnt = 0
  227.  
  228.         for cnt = 1,6 do
  229.             senderIdLrgB[cnt], vMLrgB[cnt], vPLrgB[cnt] = rednet.receive("RG"..cnt.."B",6)
  230.             print(tostring(senderIdLrgB[cnt])..":"..tostring(vMLrgB[cnt])..":"..tostring(vPLrgB[cnt]).." RG"..cnt.."B")
  231.         end
  232.  
  233.         cnt = 0
  234.  
  235. --      for cnt = 1,6 do
  236. --          print(senderIdLrgB[cnt]..":"..vMLrgB[cnt]..":"..vPLrgB[cnt].." RG"..cnt.."B")
  237. --      end
  238. --      cnt = 0
  239.  
  240.         rg1aStat = vMLrgA[1]
  241.         rg2aStat = vMLrgA[2]
  242.         rg3aStat = vMLrgA[3]
  243.         rg4aStat = vMLrgA[4]
  244.         rg5aStat = vMLrgA[5]
  245.         rg6aStat = vMLrgA[6]
  246.        
  247.         rg1bStat = vMLrgB[1]
  248.         rg2bStat = vMLrgB[2]
  249.         rg3bStat = vMLrgB[3]
  250.         rg4bStat = vMLrgB[4]
  251.         rg5bStat = vMLrgB[5]
  252.         rg6bStat = vMLrgB[6]
  253.  
  254.         if rg1bStat == "Off" then
  255.             m.setBackgroundColor(colors.red)
  256.             m.setCursorPos(42,2) m.write("RG1B")
  257.             m.setBackgroundColor(colors.black)
  258.         else
  259.             m.setBackgroundColor(colors.green)
  260.             m.setCursorPos(42,2) m.write("RG1B")
  261.             m.setBackgroundColor(colors.black)
  262.         end
  263.  
  264.         if rg1aStat == "Off" then
  265.             m.setBackgroundColor(colors.red)
  266.             m.setCursorPos(42,4) m.write("RG1A")
  267.             m.setBackgroundColor(colors.black)
  268.         else
  269.             m.setBackgroundColor(colors.green)
  270.             m.setCursorPos(42,4) m.write("RG1A")
  271.             m.setBackgroundColor(colors.black)
  272.         end
  273.  
  274.         if rg2bStat == "Off" then
  275.             m.setBackgroundColor(colors.red)
  276.             m.setCursorPos(47,2) m.write("RG2B")
  277.             m.setBackgroundColor(colors.black)
  278.         else
  279.             m.setBackgroundColor(colors.green)
  280.             m.setCursorPos(47,2) m.write("RG2B")
  281.             m.setBackgroundColor(colors.black)
  282.         end
  283.  
  284.         if rg2aStat == "Off" then
  285.             m.setBackgroundColor(colors.red)
  286.             m.setCursorPos(47,4) m.write("RG2A")
  287.             m.setBackgroundColor(colors.black)
  288.         else
  289.             m.setBackgroundColor(colors.green)
  290.             m.setCursorPos(47,4) m.write("RG2A")
  291.             m.setBackgroundColor(colors.black)
  292.         end
  293.  
  294.         if rg3bStat == "Off" then
  295.             m.setBackgroundColor(colors.red)
  296.             m.setCursorPos(52,2) m.write("RG3B")
  297.             m.setBackgroundColor(colors.black)
  298.         else
  299.             m.setBackgroundColor(colors.green)
  300.             m.setCursorPos(52,2) m.write("RG3B")
  301.             m.setBackgroundColor(colors.black)
  302.         end
  303.  
  304.         if rg3aStat == "Off" then
  305.             m.setBackgroundColor(colors.red)
  306.             m.setCursorPos(52,4) m.write("RG3A")
  307.             m.setBackgroundColor(colors.black)
  308.         else
  309.             m.setBackgroundColor(colors.green)
  310.             m.setCursorPos(52,4) m.write("RG3A")
  311.             m.setBackgroundColor(colors.black)
  312.         end
  313.  
  314.         if rg4bStat == "Off" then
  315.             m.setBackgroundColor(colors.red)
  316.             m.setCursorPos(57,2) m.write("RG4B")
  317.             m.setBackgroundColor(colors.black)
  318.         else
  319.             m.setBackgroundColor(colors.green)
  320.             m.setCursorPos(57,2) m.write("RG4B")
  321.             m.setBackgroundColor(colors.black)
  322.         end
  323.  
  324.         if rg4aStat == "Off" then
  325.             m.setBackgroundColor(colors.red)
  326.             m.setCursorPos(57,4) m.write("RG4A")
  327.             m.setBackgroundColor(colors.black)
  328.         else
  329.             m.setBackgroundColor(colors.green)
  330.             m.setCursorPos(57,4) m.write("RG4A")
  331.             m.setBackgroundColor(colors.black)
  332.         end
  333.  
  334.         if rg5bStat == "Off" then
  335.             m.setBackgroundColor(colors.red)
  336.             m.setCursorPos(62,2) m.write("RG5B")
  337.             m.setBackgroundColor(colors.black)
  338.         else
  339.             m.setBackgroundColor(colors.green)
  340.             m.setCursorPos(62,2) m.write("RG5B")
  341.             m.setBackgroundColor(colors.black)
  342.         end
  343.  
  344.         if rg5aStat == "Off" then
  345.             m.setBackgroundColor(colors.red)
  346.             m.setCursorPos(62,4) m.write("RG5A")
  347.             m.setBackgroundColor(colors.black)
  348.         else
  349.             m.setBackgroundColor(colors.green)
  350.             m.setCursorPos(62,4) m.write("RG5A")
  351.             m.setBackgroundColor(colors.black)
  352.         end
  353.        
  354.         if rg6bStat == "Off" then
  355.             m.setBackgroundColor(colors.red)
  356.             m.setCursorPos(67,2) m.write("RG6B")
  357.             m.setBackgroundColor(colors.black)
  358.         else
  359.             m.setBackgroundColor(colors.green)
  360.             m.setCursorPos(67,2) m.write("RG6B")
  361.             m.setBackgroundColor(colors.black)
  362.         end
  363.  
  364.         if rg6aStat == "Off" then
  365.             m.setBackgroundColor(colors.red)
  366.             m.setCursorPos(67,4) m.write("RG6A")
  367.             m.setBackgroundColor(colors.black)
  368.         else
  369.             m.setBackgroundColor(colors.green)
  370.             m.setCursorPos(67,4) m.write("RG6A")
  371.             m.setBackgroundColor(colors.black)
  372.         end
  373.  
  374.         cnt = 0
  375.         for cnt = 1,6 do
  376.             senderIdLrgA[cnt] = nil
  377.             vMLrgA[cnt] = nil
  378.             vPLrgA[cnt] = nil
  379.             senderIdLrgB[cnt] = nil
  380.             vMLrgB[cnt] = nil
  381.             vPLrgB[cnt] = nil
  382.         end
  383.         cnt = 0
  384.     end
  385.  
  386.  
  387. end
  388.  
  389.  function mfsuAll()
  390.     while true do
  391.         sleep(0.5)
  392.         --1 Check if peripheral is connected
  393.         if mfsu1 ~= nil then
  394.             --User value
  395.             mfsu1EUS = mfsu1.getEUStored()
  396.         else
  397.             --reconnect
  398.             mfsu1 = peripheral.wrap(mfsu_1)
  399.             if mfsu1 ~= nil then
  400.                 --Check if peripheral is connected
  401.                 mfsu1EUS = mfsu1.getEUStored()
  402.             else
  403.                 --unable to connect, set to 0
  404.                 mfsu1EUS = 0
  405.             end
  406.         end
  407.  
  408.         --2 Check if peripheral is connected
  409.         if mfsu2 ~= nil then
  410.             --User value
  411.             mfsu2EUS = mfsu2.getEUStored()
  412.         else
  413.             --reconnect
  414.             mfsu2 = peripheral.wrap(mfsu_2)
  415.             if mfsu2 ~= nil then
  416.                 --Check if peripheral is connected
  417.                 mfsu2EUS = mfsu2.getEUStored()
  418.             else
  419.                 --unable to connect, set to 0
  420.                 mfsu2EUS = 0
  421.             end
  422.         end
  423.  
  424.         --3 Check if peripheral is connected
  425.         if mfsu3 ~= nil then
  426.             --User value
  427.             mfsu3EUS = mfsu3.getEUStored()
  428.         else
  429.             --reconnect
  430.             mfsu3 = peripheral.wrap(mfsu_3)
  431.             if mfsu3 ~= nil then
  432.                 --Check if peripheral is connected
  433.                 mfsu3EUS = mfsu3.getEUStored()
  434.             else
  435.                 --unable to connect, set to 0
  436.                 mfsu3EUS = 0
  437.             end
  438.         end
  439.  
  440.         --4 Check if peripheral is connected
  441.         if mfsu4 ~= nil then
  442.             --User value
  443.             mfsu4EUS = mfsu4.getEUStored()
  444.         else
  445.             --reconnect
  446.             mfsu4 = peripheral.wrap(mfsu_4)
  447.             if mfsu4 ~= nil then
  448.                 --Check if peripheral is connected
  449.                 mfsu4EUS = mfsu4.getEUStored()
  450.             else
  451.                 --unable to connect, set to 0
  452.                 mfsu4EUS = 0
  453.             end
  454.         end
  455.        
  456.         --5 Check if peripheral is connected
  457.         if mfsu5 ~= nil then
  458.             --User value
  459.             mfsu5EUS = mfsu5.getEUStored()
  460.         else
  461.             --reconnect
  462.             mfsu5 = peripheral.wrap(mfsu_5)
  463.             if mfsu1 ~= nil then
  464.                 --Check if peripheral is connected
  465.                 mfsu5EUS = mfsu5.getEUStored()
  466.             else
  467.                 --unable to connect, set to 0
  468.                 mfsu5EUS = 0
  469.             end
  470.         end
  471.        
  472.         --6 Check if peripheral is connected
  473.         if mfsu6 ~= nil then
  474.             --User value
  475.             mfsu6EUS = mfsu6.getEUStored()
  476.         else
  477.             --reconnect
  478.             mfsu6 = peripheral.wrap(mfsu_6)
  479.             if mfsu6 ~= nil then
  480.                 --Check if peripheral is connected
  481.                 mfsu6EUS = mfsu6.getEUStored()
  482.             else
  483.                 --unable to connect, set to 0
  484.                 mfsu6EUS = 0
  485.             end
  486.         end
  487.        
  488.         --7 Check if peripheral is connected
  489.         if mfsu7 ~= nil then
  490.             --User value
  491.             mfsu7EUS = mfsu7.getEUStored()
  492.         else
  493.             --reconnect
  494.             mfsu7 = peripheral.wrap(mfsu_7)
  495.             if mfsu7 ~= nil then
  496.                 --Check if peripheral is connected
  497.                 mfsu7EUS = mfsu7.getEUStored()
  498.             else
  499.                 --unable to connect, set to 0
  500.                 mfsu7EUS = 0
  501.             end
  502.         end
  503.        
  504.         --8 Check if peripheral is connected
  505.         if mfsu8 ~= nil then
  506.             --User value
  507.             mfsu8EUS = mfsu8.getEUStored()
  508.         else
  509.             --reconnect
  510.             mfsu8 = peripheral.wrap(mfsu_8)
  511.             if mfsu8 ~= nil then
  512.                 --Check if peripheral is connected
  513.                 mfsu8EUS = mfsu8.getEUStored()
  514.             else
  515.                 --unable to connect, set to 0
  516.                 mfsu8EUS = 0
  517.             end
  518.         end
  519.  
  520.         --9 Check if peripheral is connected
  521.         if mfsu9 ~= nil then
  522.             --User value
  523.             mfsu9EUS = mfsu9.getEUStored()
  524.         else
  525.             --reconnect
  526.             mfsu9 = peripheral.wrap(mfsu_9)
  527.             if mfsu9 ~= nil then
  528.                 --Check if peripheral is connected
  529.                 mfsu9EUS = mfsu9.getEUStored()
  530.             else
  531.                 --unable to connect, set to 0
  532.                 mfsu9EUS = 0
  533.             end
  534.         end
  535.        
  536.         --10 Check if peripheral is connected
  537.         if mfsu10 ~= nil then
  538.             --User value
  539.             mfsu10EUS = mfsu10.getEUStored()
  540.         else
  541.             --reconnect
  542.             mfsu10 = peripheral.wrap(mfsu_10)
  543.             if mfsu10 ~= nil then
  544.                 --Check if peripheral is connected
  545.                 mfsu10EUS = mfsu10.getEUStored()
  546.             else
  547.                 --unable to connect, set to 0
  548.                 mfsu10EUS = 0
  549.             end
  550.         end
  551.        
  552.         --11 Check if peripheral is connected
  553.         if mfsu11 ~= nil then
  554.             --User value
  555.             mfsu11EUS = mfsu11.getEUStored()
  556.         else
  557.             --reconnect
  558.             mfsu11 = peripheral.wrap(mfsu_11)
  559.             if mfsu11 ~= nil then
  560.                 --Check if peripheral is connected
  561.                 mfsu11EUS = mfsu11.getEUStored()
  562.             else
  563.                 --unable to connect, set to 0
  564.                 mfsu11EUS = 0
  565.             end
  566.         end
  567.        
  568.         --12 Check if peripheral is connected
  569.         if mfsu12 ~= nil then
  570.             --User value
  571.             mfsu12EUS = mfsu12.getEUStored()
  572.         else
  573.             --reconnect
  574.             mfsu12 = peripheral.wrap(mfsu_12)
  575.             if mfsu12 ~= nil then
  576.                 --Check if peripheral is connected
  577.                 mfsu12EUS = mfsu12.getEUStored()
  578.             else
  579.                 --unable to connect, set to 0
  580.                 mfsu12EUS = 0
  581.             end
  582.         end
  583.        
  584.         --13 Check if peripheral is connected
  585.         if mfsu13 ~= nil then
  586.             --User value
  587.             mfsu13EUS = mfsu13.getEUStored()
  588.         else
  589.             --reconnect
  590.             mfsu13 = peripheral.wrap(mfsu_13)
  591.             if mfsu13 ~= nil then
  592.                 --Check if peripheral is connected
  593.                 mfsu13EUS = mfsu13.getEUStored()
  594.             else
  595.                 --unable to connect, set to 0
  596.                 mfsu13EUS = 0
  597.             end
  598.         end
  599.        
  600.         --14 Check if peripheral is connected
  601.         if mfsu14 ~= nil then
  602.             --User value
  603.             mfsu14EUS = mfsu14.getEUStored()
  604.         else
  605.             --reconnect
  606.             mfsu14 = peripheral.wrap(mfsu_14)
  607.             if mfsu14 ~= nil then
  608.                 --Check if peripheral is connected
  609.                 mfsu14EUS = mfsu14.getEUStored()
  610.             else
  611.                 --unable to connect, set to 0
  612.                 mfsu14EUS = 0
  613.             end
  614.         end
  615.        
  616.         --15 Check if peripheral is connected
  617.         if mfsu15 ~= nil then
  618.             --User value
  619.             mfsu15EUS = mfsu15.getEUStored()
  620.         else
  621.             --reconnect
  622.             mfsu15 = peripheral.wrap(mfsu_15)
  623.             if mfsu15 ~= nil then
  624.                 --Check if peripheral is connected
  625.                 mfsu15EUS = mfsu15.getEUStored()
  626.             else
  627.                 --unable to connect, set to 0
  628.                 mfsu15EUS = 0
  629.             end
  630.         end
  631. ---------------------------------------------------------------------------------------------------------------------------------      
  632.         --mfsug1_6 Check if peripheral is connected
  633.         if mfsug1_6 ~= nil then
  634.             --User value
  635.             mfsug1_6EUS = mfsug1_6.getEUStored()
  636.         else
  637.             --reconnect
  638.             mfsug1_6 = peripheral.wrap(v_mfsug1_6)
  639.             if mfsug1_6 ~= nil then
  640.                 --Check if peripheral is connected
  641.                 mfsug1_6EUS = mfsug1_6.getEUStored()
  642.             else
  643.                 --unable to connect, set to 0
  644.                 mfsug1_6EUS = 0
  645.             end
  646.         end
  647.        
  648.         --mfsug1_7 Check if peripheral is connected
  649.         if mfsug1_7 ~= nil then
  650.             --User value
  651.             mfsug1_7EUS = mfsug1_7.getEUStored()
  652.         else
  653.             --reconnect
  654.             mfsug1_7 = peripheral.wrap(v_mfsug1_7)
  655.             if mfsug1_7 ~= nil then
  656.                 --Check if peripheral is connected
  657.                 mfsug1_7EUS = mfsug1_7.getEUStored()
  658.             else
  659.                 --unable to connect, set to 0
  660.                 mfsug1_7EUS = 0
  661.             end
  662.         end
  663.        
  664.         --mfsug1_8 Check if peripheral is connected
  665.         if mfsug1_8 ~= nil then
  666.             --User value
  667.             mfsug1_8EUS = mfsug1_8.getEUStored()
  668.         else
  669.             --reconnect
  670.             mfsug1_8 = peripheral.wrap(v_mfsug1_8)
  671.             if mfsug1_8 ~= nil then
  672.                 --Check if peripheral is connected
  673.                 mfsug1_8EUS = mfsug1_8.getEUStored()
  674.             else
  675.                 --unable to connect, set to 0
  676.                 mfsug1_8EUS = 0
  677.             end
  678.         end
  679.        
  680.         --mfsug1_9 Check if peripheral is connected
  681.         if mfsug1_9 ~= nil then
  682.             --User value
  683.             mfsug1_9EUS = mfsug1_9.getEUStored()
  684.         else
  685.             --reconnect
  686.             mfsug1_9 = peripheral.wrap(v_mfsug1_9)
  687.             if mfsug1_9 ~= nil then
  688.                 --Check if peripheral is connected
  689.                 mfsug1_9EUS = mfsug1_9.getEUStored()
  690.             else
  691.                 --unable to connect, set to 0
  692.                 mfsug1_9EUS = 0
  693.             end
  694.         end
  695.        
  696.         --mfsug1_10 Check if peripheral is connected
  697.         if mfsug1_10 ~= nil then
  698.             --User value
  699.             mfsug1_10EUS = mfsug1_10.getEUStored()
  700.         else
  701.             --reconnect
  702.             mfsug1_10 = peripheral.wrap(v_mfsug1_10)
  703.             if mfsug1_10 ~= nil then
  704.                 --Check if peripheral is connected
  705.                 mfsug1_10EUS = mfsug1_10.getEUStored()
  706.             else
  707.                 --unable to connect, set to 0
  708.                 mfsug1_10EUS = 0
  709.             end
  710.         end
  711. ----------------------------------------------------------------------------------------------------------------------------------------
  712.         --mfsug2_6 Check if peripheral is connected
  713.         if mfsug2_6 ~= nil then
  714.             --User value
  715.             mfsug2_6EUS = mfsug2_6.getEUStored()
  716.         else
  717.             --reconnect
  718.             mfsug2_6 = peripheral.wrap(v_mfsug2_6)
  719.             if mfsug2_6 ~= nil then
  720.                 --Check if peripheral is connected
  721.                 mfsug2_6EUS = mfsug2_6.getEUStored()
  722.             else
  723.                 --unable to connect, set to 0
  724.                 mfsug2_6EUS = 0
  725.             end
  726.         end
  727.        
  728.         --mfsug2_7 Check if peripheral is connected
  729.         if mfsug2_7 ~= nil then
  730.             --User value
  731.             mfsug2_7EUS = mfsug2_7.getEUStored()
  732.         else
  733.             --reconnect
  734.             mfsug2_7 = peripheral.wrap(v_mfsug2_7)
  735.             if mfsug2_7 ~= nil then
  736.                 --Check if peripheral is connected
  737.                 mfsug2_7EUS = mfsug2_7.getEUStored()
  738.             else
  739.                 --unable to connect, set to 0
  740.                 mfsug2_7EUS = 0
  741.             end
  742.         end
  743.        
  744.         --mfsug2_8 Check if peripheral is connected
  745.         if mfsug2_8 ~= nil then
  746.             --User value
  747.             mfsug2_8EUS = mfsug2_8.getEUStored()
  748.         else
  749.             --reconnect
  750.             mfsug2_8 = peripheral.wrap(v_mfsug2_8)
  751.             if mfsug2_8 ~= nil then
  752.                 --Check if peripheral is connected
  753.                 mfsug2_8EUS = mfsug2_8.getEUStored()
  754.             else
  755.                 --unable to connect, set to 0
  756.                 mfsug2_8EUS = 0
  757.             end
  758.         end
  759.        
  760.         --mfsug2_9 Check if peripheral is connected
  761.         if mfsug2_9 ~= nil then
  762.             --User value
  763.             mfsug2_9EUS = mfsug2_9.getEUStored()
  764.         else
  765.             --reconnect
  766.             mfsug2_9 = peripheral.wrap(v_mfsug2_9)
  767.             if mfsug2_9 ~= nil then
  768.                 --Check if peripheral is connected
  769.                 mfsug2_9EUS = mfsug2_9.getEUStored()
  770.             else
  771.                 --unable to connect, set to 0
  772.                 mfsug2_9EUS = 0
  773.             end
  774.         end
  775.        
  776.         --mfsug2_10 Check if peripheral is connected
  777.         if mfsug2_10 ~= nil then
  778.             --User value
  779.             mfsug2_10EUS = mfsug2_10.getEUStored()
  780.         else
  781.             --reconnect
  782.             mfsug2_10 = peripheral.wrap(v_mfsug2_10)
  783.             if mfsug2_10 ~= nil then
  784.                 --Check if peripheral is connected
  785.                 mfsug2_10EUS = mfsug2_10.getEUStored()
  786.             else
  787.                 --unable to connect, set to 0
  788.                 mfsug2_10EUS = 0
  789.             end
  790.         end    
  791. ----------------------------------------------------------------------------------------------------------------------------------------
  792.         --mfsug3_6 Check if peripheral is connected
  793.         if mfsug3_6 ~= nil then
  794.             --User value
  795.             mfsug3_6EUS = mfsug3_6.getEUStored()
  796.         else
  797.             --reconnect
  798.             mfsug3_6 = peripheral.wrap(v_mfsug3_6)
  799.             if mfsug3_6 ~= nil then
  800.                 --Check if peripheral is connected
  801.                 mfsug3_6EUS = mfsug3_6.getEUStored()
  802.             else
  803.                 --unable to connect, set to 0
  804.                 mfsug3_6EUS = 0
  805.             end
  806.         end
  807.        
  808.         --mfsug3_7 Check if peripheral is connected
  809.         if mfsug3_7 ~= nil then
  810.             --User value
  811.             mfsug3_7EUS = mfsug3_7.getEUStored()
  812.         else
  813.             --reconnect
  814.             mfsug3_7 = peripheral.wrap(v_mfsug3_7)
  815.             if mfsug3_7 ~= nil then
  816.                 --Check if peripheral is connected
  817.                 mfsug3_7EUS = mfsug3_7.getEUStored()
  818.             else
  819.                 --unable to connect, set to 0
  820.                 mfsug3_7EUS = 0
  821.             end
  822.         end
  823.        
  824.         --mfsug3_8 Check if peripheral is connected
  825.         if mfsug3_8 ~= nil then
  826.             --User value
  827.             mfsug3_8EUS = mfsug3_8.getEUStored()
  828.         else
  829.             --reconnect
  830.             mfsug3_8 = peripheral.wrap(v_mfsug3_8)
  831.             if mfsug3_8 ~= nil then
  832.                 --Check if peripheral is connected
  833.                 mfsug3_8EUS = mfsug3_8.getEUStored()
  834.             else
  835.                 --unable to connect, set to 0
  836.                 mfsug3_8EUS = 0
  837.             end
  838.         end
  839.        
  840.         --mfsug3_9 Check if peripheral is connected
  841.         if mfsug3_9 ~= nil then
  842.             --User value
  843.             mfsug3_9EUS = mfsug3_9.getEUStored()
  844.         else
  845.             --reconnect
  846.             mfsug3_9 = peripheral.wrap(v_mfsug3_9)
  847.             if mfsug3_9 ~= nil then
  848.                 --Check if peripheral is connected
  849.                 mfsug3_9EUS = mfsug3_9.getEUStored()
  850.             else
  851.                 --unable to connect, set to 0
  852.                 mfsug3_9EUS = 0
  853.             end
  854.         end
  855.        
  856.         --mfsug3_10 Check if peripheral is connected
  857.         if mfsug3_10 ~= nil then
  858.             --User value
  859.             mfsug3_10EUS = mfsug3_10.getEUStored()
  860.         else
  861.             --reconnect
  862.             mfsug3_10 = peripheral.wrap(v_mfsug3_10)
  863.             if mfsug3_10 ~= nil then
  864.                 --Check if peripheral is connected
  865.                 mfsug3_10EUS = mfsug3_10.getEUStored()
  866.             else
  867.                 --unable to connect, set to 0
  868.                 mfsug3_10EUS = 0
  869.             end
  870.         end    
  871.  
  872.         mfsu1Perc = math.floor (mfsu1EUS / 40000000 * 100)
  873.         mfsu2Perc = math.floor (mfsu2EUS / 40000000 * 100)
  874.         mfsu3Perc = math.floor (mfsu3EUS / 40000000 * 100)
  875.         mfsu4Perc = math.floor (mfsu4EUS / 40000000 * 100)
  876.         mfsu5Perc = math.floor (mfsu5EUS / 40000000 * 100)
  877.         mfsug1_6Perc = math.floor (mfsug1_6EUS / 40000000 * 100)
  878.         mfsug1_7Perc = math.floor (mfsug1_7EUS / 40000000 * 100)
  879.         mfsug1_8Perc = math.floor (mfsug1_8EUS / 40000000 * 100)
  880.         mfsug1_9Perc = math.floor (mfsug1_9EUS / 40000000 * 100)
  881.         mfsug1_10Perc = math.floor (mfsug1_10EUS / 40000000 * 100)     
  882.        
  883.         mfsu6Perc = math.floor (mfsu6EUS / 40000000 * 100)
  884.         mfsu7Perc = math.floor (mfsu7EUS / 40000000 * 100)
  885.         mfsu8Perc = math.floor (mfsu8EUS / 40000000 * 100)
  886.         mfsu9Perc = math.floor (mfsu9EUS / 40000000 * 100)
  887.         mfsu10Perc = math.floor (mfsu10EUS / 40000000 * 100)
  888.         mfsug2_6Perc = math.floor (mfsug2_6EUS / 40000000 * 100)
  889.         mfsug2_7Perc = math.floor (mfsug2_7EUS / 40000000 * 100)
  890.         mfsug2_8Perc = math.floor (mfsug2_8EUS / 40000000 * 100)
  891.         mfsug2_9Perc = math.floor (mfsug2_9EUS / 40000000 * 100)
  892.         mfsug2_10Perc = math.floor (mfsug2_10EUS / 40000000 * 100)
  893.        
  894.         mfsu11Perc = math.floor (mfsu11EUS / 40000000 * 100)
  895.         mfsu12Perc = math.floor (mfsu12EUS / 40000000 * 100)
  896.         mfsu13Perc = math.floor (mfsu13EUS / 40000000 * 100)
  897.         mfsu14Perc = math.floor (mfsu14EUS / 40000000 * 100)
  898.         mfsu15Perc = math.floor (mfsu15EUS / 40000000 * 100)
  899.         mfsug3_6Perc = math.floor (mfsug3_6EUS / 40000000 * 100)
  900.         mfsug3_7Perc = math.floor (mfsug3_7EUS / 40000000 * 100)
  901.         mfsug3_8Perc = math.floor (mfsug3_8EUS / 40000000 * 100)
  902.         mfsug3_9Perc = math.floor (mfsug3_9EUS / 40000000 * 100)
  903.         mfsug3_10Perc = math.floor (mfsug3_10EUS / 40000000 * 100)
  904.        
  905.         m.setCursorPos(43,7) m.write("grp 1")
  906.         m.setCursorPos(43,8) m.write("R1B1 :"..mfsu2Perc.."%   ") m.setCursorPos(60,8) m.write("R2B1 :"..mfsu4Perc.."%   ")
  907.         m.setCursorPos(43,9) m.write("R1B2 :"..mfsug1_6Perc.."%   ") m.setCursorPos(60,9) m.write("R2B2 :"..mfsug1_7Perc.."%   ")
  908.         m.setCursorPos(45,10) m.write("GRP1A :"..mfsu5Perc.."% >>   ") m.setCursorPos(61,10) m.write("GRP1B :"..mfsug1_10Perc.."%   ")
  909.         m.setCursorPos(43,11) m.write("R1A2 :"..mfsug1_8Perc.."%   ") m.setCursorPos(60,11) m.write("R2A2 :"..mfsug1_9Perc.."%   ")
  910.         m.setCursorPos(43,12) m.write("R1A1 :"..mfsu1Perc.."%   ") m.setCursorPos(60,12) m.write("R2A1 :"..mfsu3Perc.."%   ")
  911.        
  912.         m.setCursorPos(43,14) m.write("grp 2")
  913.         m.setCursorPos(43,15) m.write("R3B1 :"..mfsu7Perc.."%   ") m.setCursorPos(60,15) m.write("R4B1 :"..mfsu9Perc.."%   ")
  914.         m.setCursorPos(43,16) m.write("R3B2 :"..mfsug2_6Perc.."%   ") m.setCursorPos(60,16) m.write("R4B2 :"..mfsug2_7Perc.."%   ")
  915.         m.setCursorPos(45,17) m.write("GRP3A :"..mfsu10Perc.."% >>   ") m.setCursorPos(61,17) m.write("GRP2B :"..mfsug2_10Perc.."%   ")
  916.         m.setCursorPos(43,18) m.write("R3A2 :"..mfsug2_8Perc.."%   ") m.setCursorPos(60,18) m.write("R4A2 :"..mfsug2_9Perc.."%   ")
  917.         m.setCursorPos(43,19) m.write("R3A1 :"..mfsu6Perc.."%   ") m.setCursorPos(60,19) m.write("R4A1 :"..mfsu8Perc.."%   ")
  918.        
  919.         m.setCursorPos(43,21) m.write("grp 3")
  920.         m.setCursorPos(43,22) m.write("R5B1 :"..mfsu12Perc.."%   ") m.setCursorPos(60,22) m.write("R6B1 :"..mfsu14Perc.."%   ")
  921.         m.setCursorPos(43,23) m.write("R5B2 :"..mfsug3_6Perc.."%   ") m.setCursorPos(60,23) m.write("R6B2 :"..mfsug3_7Perc.."%   ")
  922.         m.setCursorPos(45,24) m.write("GRP3A :"..mfsu15Perc.."% >>   ") m.setCursorPos(61,24) m.write("GRP2B :"..mfsug3_10Perc.."%   ")
  923.         m.setCursorPos(43,25) m.write("R5A2 :"..mfsug3_8Perc.."%   ") m.setCursorPos(60,25) m.write("R6A2 :"..mfsug3_9Perc.."%   ")
  924.         m.setCursorPos(43,26) m.write("R5A1 :"..mfsu11Perc.."%   ") m.setCursorPos(60,26) m.write("R6A1 :"..mfsu13Perc.."%   ")
  925.    
  926.         sleep(1)
  927.     end
  928. end
  929.  
  930. function LiquidTanksAll()
  931.     tank1 = peripheral.wrap(rfp1)
  932.     tank2 = peripheral.wrap(rfp2)
  933.     tank3 = peripheral.wrap(rfp3)
  934.     tank4 = peripheral.wrap(rfp4)
  935.     tank5 = peripheral.wrap(rfp5)
  936.     tank6 = peripheral.wrap(rfp6)
  937.  
  938.     EmptyCounter1 = 0
  939.     EmptyCounter2 = 0
  940.     EmptyCounter3 = 0
  941.     EmptyCounter4 = 0
  942.     EmptyCounter5 = 0
  943.     EmptyCounter6 = 0
  944.    
  945.     while true do
  946.         m.setCursorPos(45,1)
  947.         tank1I = tank1.getTankInfo()
  948.         tank2I = tank2.getTankInfo()
  949.         tank3I = tank3.getTankInfo()
  950.         tank4I = tank4.getTankInfo()
  951.         tank5I = tank5.getTankInfo()
  952.         tank6I = tank6.getTankInfo()
  953.  
  954. -- begin Reactor 1
  955.         if tank1I[1]["contents"] == nil then
  956.             EmptyCounter1 = EmptyCounter1 + 1
  957.             ic2c1ValueC = "0"
  958.         else
  959.             EmptyCounter1 = 0
  960.             if tank1I[1]["contents"]["name"] == "ic2coolant" then
  961.                 ic2c1 = tank1I[1]
  962.                 ic2c1ValueC = ic2c1["contents"]["amount"]
  963.             elseif tank1I[1]["contents"]["name"] == "ic2hotcoolant" then
  964.                 ic2hc1 = tank1I[1]
  965.                 ic2hc1ValueC = ic2hc1["contents"]["amount"]
  966.             else
  967.                 error("R1 Incorrect liquid in "..tank1I[1]["contents"]["name"])
  968.             end
  969.             if tank1I[2]["contents"] ~= nil then
  970.                 if tank1I[2]["contents"]["name"] == "ic2coolant" then
  971.                     ic2c1 = tank1I[2]
  972.                     ic2c1ValueC = ic2c1["contents"]["amount"]
  973.                 elseif tank1I[2]["contents"]["name"] == "ic2hotcoolant" then
  974.                     ic2hc1 = tank1I[2]
  975.                     ic2hc1ValueC = ic2hc1["contents"]["amount"]
  976.                 else
  977.                     error("R1 Incorrect liquid in "..tank1I[1]["contents"]["name"])
  978.                 end
  979.             else
  980.                 ic2hc1ValueC = "0"
  981.             end
  982.            
  983.             --R1
  984.             x1 = ic2c1ValueC / 10000 * 100
  985.             m.setCursorPos(22,2) m.setBackgroundColor(colors.cyan)
  986.             if x1 < 50 then
  987.                 m.write("warning!! Coolant LOW :"..math.floor(x1).."% full.....")
  988.             else
  989.                 m.write("C  : "..math.floor(x1).."% full")
  990.             end
  991.             m.setBackgroundColor(colors.black)
  992.            
  993.             y1 = ic2hc1ValueC / 10000 * 100
  994.             m.setCursorPos(22,4) m.setBackgroundColor(colors.red)
  995.             if y1 > 50 then
  996.                 m.write("warning!! HC HIGH :"..math.floor(y1).."% full.....")
  997.             else
  998. --              m.write("HC : "..math.floor(y1).."% full")
  999.                 m.write("HC : "..ic2hc1ValueC.." full.....")
  1000.             end
  1001.             m.setBackgroundColor(colors.black)
  1002. --          sleep(0.5)
  1003.         end
  1004. -- end Reactor 1
  1005. -- begin Reactor 2
  1006.         if tank2I[1]["contents"] == nil then
  1007.             EmptyCounter2 = EmptyCounter2 + 1
  1008.             ic2c2ValueC = "0"
  1009.         else
  1010.             EmptyCounter2 = 0
  1011.             if tank2I[1]["contents"]["name"] == "ic2coolant" then
  1012.                 ic2c2 = tank2I[1]
  1013.                 ic2c2ValueC = ic2c2["contents"]["amount"]
  1014.             elseif tank2I[1]["contents"]["name"] == "ic2hotcoolant" then
  1015.                 ic2hc2 = tank2I[1]
  1016.                 ic2hc2ValueC = ic2hc2["contents"]["amount"]
  1017.             else
  1018.                 error("R2 Incorrect liquid in "..tank2I[1]["contents"]["name"])
  1019.             end
  1020.             if tank2I[2]["contents"] ~= nil then
  1021.                 if tank2I[2]["contents"]["name"] == "ic2coolant" then
  1022.                     ic2c2 = tank2I[2]
  1023.                     ic2c2ValueC = ic2c2["contents"]["amount"]
  1024.                 elseif tank2I[2]["contents"]["name"] == "ic2hotcoolant" then
  1025.                     ic2hc2 = tank2I[2]
  1026.                     ic2hc2ValueC = ic2hc2["contents"]["amount"]
  1027.                 else
  1028.                     error("R2 Incorrect liquid in "..tank2I[1]["contents"]["name"])
  1029.                 end
  1030.             else
  1031.                 ic2hc2ValueC = "0"
  1032.             end
  1033.            
  1034.             --R2
  1035.             x2 = ic2c2ValueC / 20000 * 200
  1036.             m.setCursorPos(22,6) m.setBackgroundColor(colors.cyan)
  1037.             if x2 < 50 then
  1038.                 m.write("warning!! Coolant LOW :"..math.floor(x2).."% full.....")
  1039.             else
  1040.                 m.write("C  : "..math.floor(x2).."% full")
  1041.             end
  1042.             m.setBackgroundColor(colors.black)
  1043.            
  1044.             y2 = ic2hc2ValueC / 20000 * 200
  1045.             m.setCursorPos(22,8) m.setBackgroundColor(colors.red)
  1046.             if y2 > 50 then
  1047.                 m.write("warning!! HC HIGH :"..math.floor(y2).."% full.....")
  1048.             else
  1049. --              m.write("HC : "..math.floor(y2).."% full")
  1050.                 m.write("HC : "..ic2hc2ValueC.." full.....")
  1051.             end
  1052.             m.setBackgroundColor(colors.black)
  1053. --          sleep(0.5)     
  1054.         end
  1055. -- end Reactor 2
  1056. -- begin Reactor 3
  1057.         if tank3I[1]["contents"] == nil then
  1058.             EmptyCounter3 = EmptyCounter3 + 1
  1059.             ic2c3ValueC = "0"
  1060.         else
  1061.             EmptyCounter3 = 0
  1062.             if tank3I[1]["contents"]["name"] == "ic2coolant" then
  1063.                 ic2c3 = tank3I[1]
  1064.                 ic2c3ValueC = ic2c3["contents"]["amount"]
  1065.             elseif tank3I[1]["contents"]["name"] == "ic2hotcoolant" then
  1066.                 ic2hc3 = tank3I[1]
  1067.                 ic2hc3ValueC = ic2hc3["contents"]["amount"]
  1068.             else
  1069.                 error("R3 Incorrect liquid in "..tank3I[1]["contents"]["name"])
  1070.             end
  1071.             if tank3I[2]["contents"] ~= nil then
  1072.                 if tank3I[2]["contents"]["name"] == "ic2coolant" then
  1073.                     ic2c3 = tank3I[2]
  1074.                     ic2c3ValueC = ic2c3["contents"]["amount"]
  1075.                 elseif tank3I[2]["contents"]["name"] == "ic2hotcoolant" then
  1076.                     ic2hc3 = tank3I[2]
  1077.                     ic2hc3ValueC = ic2hc3["contents"]["amount"]
  1078.                 else
  1079.                     error("R3 Incorrect liquid in "..tank3I[1]["contents"]["name"])
  1080.                 end
  1081.             else
  1082.                 ic2hc3ValueC = "0"
  1083.             end
  1084.            
  1085.             --R3
  1086.             x3 = ic2c3ValueC / 30000 * 300
  1087.             m.setCursorPos(22,10) m.setBackgroundColor(colors.cyan)
  1088.             if x3 < 50 then
  1089.                 m.write("warning!! Coolant LOW :"..math.floor(x3).."% full.....")
  1090.             else
  1091.                 m.write("C  : "..math.floor(x3).."% full")
  1092.             end
  1093.             m.setBackgroundColor(colors.black)
  1094.            
  1095.             y3 = ic2hc3ValueC / 30000 * 300
  1096.             m.setCursorPos(22,12) m.setBackgroundColor(colors.red)
  1097.             if y3 > 50 then
  1098.                 m.write("warning!! HC HIGH :"..math.floor(y3).."% full.....")
  1099.             else
  1100. --              m.write("HC : "..math.floor(y3).."% full")
  1101.                 m.write("HC : "..ic2hc3ValueC.." full.....")
  1102.             end
  1103.             m.setBackgroundColor(colors.black)
  1104. --          sleep(0.5)     
  1105.         end
  1106. -- end Reactor 3
  1107. -- begin Reactor 4
  1108.         if tank4I[1]["contents"] == nil then
  1109.             EmptyCounter4 = EmptyCounter4 + 1
  1110.             ic2c4ValueC = "0"
  1111.         else
  1112.             EmptyCounter4 = 0
  1113.             if tank4I[1]["contents"]["name"] == "ic2coolant" then
  1114.                 ic2c4 = tank4I[1]
  1115.                 ic2c4ValueC = ic2c4["contents"]["amount"]
  1116.             elseif tank4I[1]["contents"]["name"] == "ic2hotcoolant" then
  1117.                 ic2hc4 = tank4I[1]
  1118.                 ic2hc4ValueC = ic2hc4["contents"]["amount"]
  1119.             else
  1120.                 error("R4 Incorrect liquid in "..tank4I[1]["contents"]["name"])
  1121.             end
  1122.             if tank4I[2]["contents"] ~= nil then
  1123.                 if tank4I[2]["contents"]["name"] == "ic2coolant" then
  1124.                     ic2c4 = tank4I[2]
  1125.                     ic2c4ValueC = ic2c4["contents"]["amount"]
  1126.                 elseif tank4I[2]["contents"]["name"] == "ic2hotcoolant" then
  1127.                     ic2hc4 = tank4I[2]
  1128.                     ic2hc4ValueC = ic2hc4["contents"]["amount"]
  1129.                 else
  1130.                     error("R4 Incorrect liquid in "..tank4I[1]["contents"]["name"])
  1131.                 end
  1132.             else
  1133.                 ic2hc4ValueC = "0"
  1134.             end
  1135.            
  1136.             --R4
  1137.             x4 = ic2c4ValueC / 40000 * 400
  1138.             m.setCursorPos(22,14) m.setBackgroundColor(colors.cyan)
  1139.             if x4 < 50 then
  1140.                 m.write("warning!! Coolant LOW :"..math.floor(x4).."% full.....")
  1141.             else
  1142.                 m.write("C  : "..math.floor(x4).."% full")
  1143.             end
  1144.             m.setBackgroundColor(colors.black)
  1145.            
  1146.             y4 = ic2hc4ValueC / 40000 * 400
  1147.             m.setCursorPos(22,16) m.setBackgroundColor(colors.red)
  1148.             if y4 > 50 then
  1149.                 m.write("warning!! HC HIGH :"..math.floor(y4).."% full.....")
  1150.             else
  1151. --              m.write("HC : "..math.floor(y4).."% full")
  1152.                 m.write("HC : "..ic2hc4ValueC.." full.....")
  1153.             end
  1154.             m.setBackgroundColor(colors.black)
  1155. --          sleep(0.5)     
  1156.         end
  1157. -- end Reactor 4
  1158. -- begin Reactor 5
  1159.         if tank5I[1]["contents"] == nil then
  1160.             EmptyCounter5 = EmptyCounter5 + 1
  1161.             ic2c5ValueC = "0"
  1162.         elseif tank5I[2] == nil then
  1163.             EmptyCounter5 = EmptyCounter5 + 1
  1164.         else
  1165.             EmptyCounter5 = 0
  1166.             if tank5I[1]["contents"]["name"] == "ic2coolant" then
  1167.                 ic2c5 = tank5I[1]
  1168.                 ic2c5ValueC = ic2c5["contents"]["amount"]
  1169.             elseif tank5I[1]["contents"]["name"] == "ic2hotcoolant" then
  1170.                 ic2hc5 = tank5I[1]
  1171.                 ic2hc5ValueC = ic2hc5["contents"]["amount"]
  1172.             else
  1173.                 error("R5 Incorrect liquid in "..tank5I[1]["contents"]["name"])
  1174.             end
  1175.             if tank5I[2]["contents"] ~= nil then
  1176.                 if tank5I[2]["contents"]["name"] == "ic2coolant" then
  1177.                     ic2c5 = tank5I[2]
  1178.                     ic2c5ValueC = ic2c5["contents"]["amount"]
  1179.                 elseif tank5I[2]["contents"]["name"] == "ic2hotcoolant" then
  1180.                     ic2hc5 = tank5I[2]
  1181.                     ic2hc5ValueC = ic2hc5["contents"]["amount"]
  1182.                 else
  1183.                     error("R5 Incorrect liquid in "..tank5I[1]["contents"]["name"])
  1184.                 end
  1185.             else
  1186.                 ic2hc5ValueC = "0"
  1187.             end
  1188.            
  1189.             --R5
  1190.             x5 = ic2c5ValueC / 50000 * 500
  1191.             m.setCursorPos(22,18) m.setBackgroundColor(colors.cyan)
  1192.             if x5 < 50 then
  1193.                 m.write("warning!! Coolant LOW :"..math.floor(x5).."% full.....")
  1194.             else
  1195.                 m.write("C  : "..math.floor(x5).."% full")
  1196.             end
  1197.             m.setBackgroundColor(colors.black)
  1198.            
  1199.             y5 = ic2hc5ValueC / 50000 * 500
  1200.             m.setCursorPos(22,20) m.setBackgroundColor(colors.red)
  1201.             if y5 > 50 then
  1202.                 m.write("warning!! HC HIGH :"..math.floor(y5).."% full.....")
  1203.             else
  1204. --              m.write("HC : "..math.floor(y5).."% full")
  1205.                 m.write("HC : "..ic2hc5ValueC.." full.....")
  1206.             end
  1207.             m.setBackgroundColor(colors.black)
  1208. --          sleep(0.5)     
  1209.         end
  1210. -- end Reactor 5
  1211. -- begin Reactor 6
  1212.         if tank6I[1]["contents"] == nil then
  1213.             EmptyCounter6 = EmptyCounter6 + 1
  1214.             ic2c6ValueC = "0"
  1215.         elseif tank6I[2] == nil then
  1216.             EmptyCounter6 = EmptyCounter6 + 1
  1217.         else
  1218.             EmptyCounter6 = 0
  1219.             if tank6I[1]["contents"]["name"] == "ic2coolant" then
  1220.                 ic2c6 = tank6I[1]
  1221.                 ic2c6ValueC = ic2c6["contents"]["amount"]
  1222.             elseif tank6I[1]["contents"]["name"] == "ic2hotcoolant" then
  1223.                 ic2hc6 = tank6I[1]
  1224.                 ic2hc6ValueC = ic2hc6["contents"]["amount"]
  1225.             else
  1226.                 error("R6 Incorrect liquid in "..tank6I[1]["contents"]["name"])
  1227.             end
  1228.             if tank6I[2]["contents"] ~= nil then
  1229.                 if tank6I[2]["contents"]["name"] == "ic2coolant" then
  1230.                     ic2c6 = tank6I[2]
  1231.                     ic2c6ValueC = ic2c6["contents"]["amount"]
  1232.                 elseif tank6I[2]["contents"]["name"] == "ic2hotcoolant" then
  1233.                     ic2hc6 = tank6I[2]
  1234.                     ic2hc6ValueC = ic2hc6["contents"]["amount"]
  1235.                 else
  1236.                     error("R6 Incorrect liquid in "..tank6I[1]["contents"]["name"])
  1237.                 end
  1238.             else
  1239.                 ic2hc6ValueC = "0"
  1240.             end
  1241.            
  1242.             --R6
  1243.             x6 = ic2c6ValueC / 60000 * 600
  1244.             m.setCursorPos(22,22) m.setBackgroundColor(colors.cyan)
  1245.             if x6 < 60 then
  1246.                 m.write("warning!! Coolant LOW :"..math.floor(x6).."% full.....")
  1247.             else
  1248.                 m.write("C  : "..math.floor(x6).."% full")
  1249.             end
  1250.             m.setBackgroundColor(colors.black)
  1251.            
  1252.             y6 = ic2hc6ValueC / 60000 * 600
  1253.             m.setCursorPos(22,24) m.setBackgroundColor(colors.red)
  1254.             if y6 > 60 then
  1255.                 m.write("warning!! HC HIGH :"..math.floor(y6).."% full.....")
  1256.             else
  1257. --              m.write("HC : "..math.floor(y6).."% full")
  1258.                 m.write("HC : "..ic2hc6ValueC.." full.....")
  1259.             end
  1260.             m.setBackgroundColor(colors.black)
  1261. --          sleep(0.6)     
  1262.         end
  1263. -- end Reactor 6
  1264.     sleep(1)
  1265.     end
  1266. end
  1267.  
  1268. function fillTable()
  1269.     button.setTable("Reactor1",Reactor1,2,15,2,4)
  1270.     button.setTable("Reactor2",Reactor2,2,15,6,8)
  1271.     button.setTable("Reactor3",Reactor3,2,15,10,12)
  1272.     button.setTable("Reactor4",Reactor4,2,15,14,16)
  1273.     button.setTable("Reactor5",Reactor5,2,15,18,20)
  1274.     button.setTable("Reactor6",Reactor6,2,15,22,24)
  1275.     button.setTable("Turn Off ALL",TurnOffALL,2,15,26,28)
  1276.     button.screen()
  1277. end
  1278.  
  1279.  
  1280. function listen()
  1281.     while true do
  1282.         local senderIdL1, messageL1, protocolL1 = rednet.receive("rc1",3)
  1283.         local senderIdL2, messageL2, protocolL2 = rednet.receive("rc2",3)
  1284.         local senderIdL3, messageL3, protocolL3 = rednet.receive("rc3",3)
  1285.         local senderIdL4, messageL4, protocolL4 = rednet.receive("rc4",3)
  1286.         local senderIdL5, messageL5, protocolL5 = rednet.receive("rc5",3)
  1287.         local senderIdL6, messageL6, protocolL6 = rednet.receive("rc6",3)
  1288.  
  1289.         if vML1rgA ~= nil then
  1290.             print("message from RC1:"..vML1rgA)
  1291.             vRG1A = vML1rgA
  1292.         else
  1293.             xm1 = xm1 + 1
  1294.             print("Got no message from RC1 ("..xm1..")")
  1295.         end
  1296.        
  1297.         if messageL1 ~= nil then
  1298.             print("message from RC1:"..messageL1)
  1299.             R1OnOff = messageL1
  1300.         else
  1301.             xm1 = xm1 + 1
  1302.             print("Got no message from RC1 ("..xm1..")")
  1303.         end
  1304.  
  1305.         if messageL2 ~= nil then
  1306.             print("message from RC2:"..messageL2)
  1307.             R2OnOff = messageL2
  1308.         else
  1309.             xm2 = xm2 + 1
  1310.             print("Got no message from RC2 ("..xm2..")")
  1311.         end
  1312.  
  1313.         if messageL3 ~= nil then
  1314. --          print("message from RC3:"..messageL3)
  1315.             R3OnOff = messageL3
  1316.         else
  1317.             xm3 = xm3 + 1
  1318.             print("Got no message from RC3 ("..xm3..")")
  1319.         end
  1320.  
  1321.         if messageL4 ~= nil then
  1322. --          print("message from RC4:"..messageL4)
  1323.             R4OnOff = messageL4
  1324.         else
  1325.             xm4 = xm4 + 1
  1326.             print("Got no message from RC4 ("..xm4..")")
  1327.         end
  1328.  
  1329.         if messageL5 ~= nil then
  1330. --          print("message from RC5:"..messageL5)
  1331.             R5OnOff = messageL5
  1332.         else
  1333.             xm5 = xm5 + 1
  1334.             print("Got no message from RC5 ("..xm5..")")
  1335.         end
  1336.  
  1337.         if messageL6 ~= nil then
  1338. --          print("message from RC6:"..messageL6)
  1339.             R6OnOff = messageL6
  1340.         else
  1341.             xm6 = xm6 + 1
  1342.             print("Got no message from RC6 ("..xm4..")")
  1343.         end    
  1344.         sleep(0,5)
  1345.        
  1346.     end
  1347. end
  1348.  
  1349.  
  1350. function urs()
  1351. --Update Reactor status
  1352. --  listenx = 1
  1353.     while true do
  1354. --      print("R1OnOff:"..R1OnOff)
  1355. --      print("R2OnOff:"..R2OnOff)
  1356. --      print("R3OnOff:"..R3OnOff)
  1357. --      print("R4OnOff:"..R4OnOff)
  1358. --      print("R5OnOff:"..R5OnOff)
  1359. --      print("R6OnOff:"..R6OnOff)
  1360.  
  1361.         if R1OnOff == "Off" then
  1362.             m.setBackgroundColor(colors.red)
  1363.             m.setCursorPos(18,3) m.write("Off")
  1364.             m.setBackgroundColor(colors.black)
  1365.         elseif R1OnOff == "On" then
  1366.             m.setBackgroundColor(colors.green)
  1367.             m.setCursorPos(18,3) m.write("On ")
  1368.             m.setBackgroundColor(colors.black)
  1369.         elseif R1OnOff == "mOn" then
  1370.             m.setBackgroundColor(colors.blue)
  1371.             m.setCursorPos(18,3) m.write("mOn")
  1372.             m.setBackgroundColor(colors.black)
  1373.         elseif R1OnOff == "NUL" then
  1374.             m.setBackgroundColor(colors.orange)
  1375.             m.setCursorPos(18,3) m.write("NUL")
  1376.             m.setBackgroundColor(colors.black)
  1377.         end
  1378.  
  1379.         if R2OnOff == "Off" then
  1380.             m.setBackgroundColor(colors.red)
  1381.             m.setCursorPos(18,7) m.write("Off")
  1382.             m.setBackgroundColor(colors.black)
  1383.         elseif R2OnOff == "On" then
  1384.             m.setBackgroundColor(colors.green)
  1385.             m.setCursorPos(18,7) m.write("On ")
  1386.             m.setBackgroundColor(colors.black)
  1387.         elseif R2OnOff == "mOn" then
  1388.             m.setBackgroundColor(colors.blue)
  1389.             m.setCursorPos(18,7) m.write("mOn")
  1390.             m.setBackgroundColor(colors.black)
  1391.         elseif R2OnOff == "NUL" then
  1392.             m.setBackgroundColor(colors.orange)
  1393.             m.setCursorPos(18,7) m.write("NUL")
  1394.             m.setBackgroundColor(colors.black)
  1395.         end
  1396.  
  1397.         if R3OnOff == "Off" then
  1398.             m.setBackgroundColor(colors.red)
  1399.             m.setCursorPos(18,11) m.write("Off")
  1400.             m.setBackgroundColor(colors.black)
  1401.         elseif R3OnOff == "On" then
  1402.             m.setBackgroundColor(colors.green)
  1403.             m.setCursorPos(18,11) m.write("On ")
  1404.             m.setBackgroundColor(colors.black)
  1405.         elseif R3OnOff == "mOn" then
  1406.             m.setBackgroundColor(colors.blue)
  1407.             m.setCursorPos(18,11) m.write("mOn")
  1408.             m.setBackgroundColor(colors.black)
  1409.         elseif R3OnOff == "NUL" then
  1410.             m.setBackgroundColor(colors.orange)
  1411.             m.setCursorPos(18,11) m.write("NUL")
  1412.             m.setBackgroundColor(colors.black)
  1413.         end
  1414.  
  1415.         if R4OnOff == "Off" then
  1416.             m.setBackgroundColor(colors.red)
  1417.             m.setCursorPos(18,15) m.write("Off")
  1418.             m.setBackgroundColor(colors.black)
  1419.         elseif R4OnOff == "On" then
  1420.             m.setBackgroundColor(colors.green)
  1421.             m.setCursorPos(18,15) m.write("On ")
  1422.             m.setBackgroundColor(colors.black)
  1423.         elseif R4OnOff == "mOn" then
  1424.             m.setBackgroundColor(colors.blue)
  1425.             m.setCursorPos(18,15) m.write("mOn")
  1426.             m.setBackgroundColor(colors.black)
  1427.         elseif R4OnOff == "NUL" then
  1428.             m.setBackgroundColor(colors.orange)
  1429.             m.setCursorPos(18,15) m.write("NUL")
  1430.             m.setBackgroundColor(colors.black)
  1431.         end
  1432.  
  1433.         if R5OnOff == "Off" then
  1434.             m.setBackgroundColor(colors.red)
  1435.             m.setCursorPos(18,19) m.write("Off")
  1436.             m.setBackgroundColor(colors.black)
  1437.         elseif R5OnOff == "On" then
  1438.             m.setBackgroundColor(colors.green)
  1439.             m.setCursorPos(18,19) m.write("On ")
  1440.             m.setBackgroundColor(colors.black)
  1441.         elseif R5OnOff == "mOn" then
  1442.             m.setBackgroundColor(colors.blue)
  1443.             m.setCursorPos(18,19) m.write("mOn")
  1444.             m.setBackgroundColor(colors.black)
  1445.         elseif R5OnOff == "NUL" then
  1446.             m.setBackgroundColor(colors.orange)
  1447.             m.setCursorPos(18,19) m.write("NUL")
  1448.             m.setBackgroundColor(colors.black)
  1449.         end
  1450.  
  1451.         if R6OnOff == "Off" then
  1452.             m.setBackgroundColor(colors.red)
  1453.             m.setCursorPos(18,23) m.write("Off")
  1454.             m.setBackgroundColor(colors.black)
  1455.         elseif R6OnOff == "On" then
  1456.             m.setBackgroundColor(colors.green)
  1457.             m.setCursorPos(18,23) m.write("On ")
  1458.             m.setBackgroundColor(colors.black)
  1459.         elseif R6OnOff == "mOn" then
  1460.             m.setBackgroundColor(colors.blue)
  1461.             m.setCursorPos(18,23) m.write("mOn")
  1462.             m.setBackgroundColor(colors.black)
  1463.         elseif R6OnOff == "NUL" then
  1464.             m.setBackgroundColor(colors.orange)
  1465.             m.setCursorPos(18,23) m.write("NUL")
  1466.             m.setBackgroundColor(colors.black)
  1467.         end
  1468.  
  1469.         sleep(0,5)
  1470.     end
  1471. end
  1472.  
  1473. function R1On()
  1474.     print("Button 1 doet niets")
  1475. end
  1476.  
  1477. function R2On()
  1478.     print("Button 2 doet niets")
  1479. end
  1480.  
  1481. function R3On()
  1482.     print("Button 3 doet niets")
  1483. end
  1484.  
  1485. function R4On()
  1486.     print("Button 4 doet niets")
  1487. end
  1488.  
  1489. function R5On()
  1490.     print("Button 5 doet niets")
  1491. end
  1492.  
  1493. function R6On()
  1494.     print("Button 6 doet niets")
  1495. end
  1496.  
  1497. function getClick()
  1498.     while true do
  1499.         event,side,x,y = os.pullEvent("monitor_touch")
  1500.         button.checkxy(x, y)
  1501.     end
  1502. end                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  1503. function pulse()
  1504.     redstone.setOutput("back", true)
  1505.     sleep(0,5)
  1506.     redstone.setOutput("back", false)
  1507. end
  1508.  
  1509. function Reactor1()
  1510.     rednet.send(rc1,"TOR1","rctrl")
  1511.     button.flash("Reactor1")
  1512. end
  1513.  
  1514. function Reactor2()
  1515.     rednet.send(rc2,"TOR2","rctrl")
  1516.     button.flash("Reactor2")
  1517. end
  1518.  
  1519. function Reactor3()
  1520.     rednet.send(rc3,"TOR3","rctrl")
  1521.     button.flash("Reactor3")
  1522. end
  1523.  
  1524. function Reactor4()
  1525.     rednet.send(rc4,"TOR4","rctrl")
  1526.     button.flash("Reactor4")
  1527. end
  1528.  
  1529. function Reactor5()
  1530.     rednet.send(rc5,"TOR5","rctrl")
  1531.     button.flash("Reactor5")
  1532. end
  1533.  
  1534. function Reactor6()
  1535.     rednet.send(rc6,"TOR6","rctrl")
  1536.     button.flash("Reactor6")
  1537. end
  1538.  
  1539. function TurnOffALL()
  1540.     Reactor1()
  1541.     Reactor2()
  1542.     Reactor3()
  1543.     Reactor4()
  1544.     Reactor5()
  1545.     Reactor6()
  1546. end
  1547.  
  1548. fillTable()
  1549.  
  1550. m.setCursorPos(43,6)
  1551. m.write("----------------------------------------------------------------")
  1552.  
  1553. x1=0
  1554.  
  1555. while true do
  1556. --  x1=x1 + 1
  1557.     parallel.waitForAny(urs, listen, getClick , LiquidTanksAll, mfsuAll, rgCheck)
  1558.     print("sleep:"..x1)
  1559.     sleep(0.5)
  1560. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement