Advertisement
loepie

GrootScherm

Mar 12th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.46 KB | None | 0 0
  1. os.loadAPI("button")
  2. m = peripheral.wrap("monitor_0")
  3. p = peripheral.wrap("back")
  4. os.loadAPI("/rom/apis/rednet")
  5. rednet.open("bottom")
  6. m.clear()
  7.  
  8. local rfp1 = "reactor_fluid_port_14"    -- Location Reactor Fluid Port
  9. local rfp2 = "reactor_fluid_port_8"     -- Location Reactor Fluid Port
  10. local rfp3 = "reactor_fluid_port_9"     -- Location Reactor Fluid Port
  11. local rfp4 = "reactor_fluid_port_10"    -- Location Reactor Fluid Port
  12. local rfp5 = "reactor_fluid_port_11"    -- Location Reactor Fluid Port
  13. local rfp6 = "reactor_fluid_port_12"    -- Location Reactor Fluid Port
  14. local nr1 = "nuclear_reactor_1"     -- Location Reactor Access Hatch
  15. local nr2 = "nuclear_reactor_2"     -- Location Reactor Access Hatch
  16. local nr3 = "nuclear_reactor_3"     -- Location Reactor Access Hatch
  17. local nr4 = "nuclear_reactor_4"     -- Location Reactor Access Hatch
  18. local nr5 = "nuclear_reactor_5"     -- Location Reactor Access Hatch
  19. local nr6 = "nuclear_reactor_6"     -- Location Reactor Access Hatch
  20. local mfsu1 = "mfsu_0"  -- Location MFSU1
  21. local mfsu2 = "mfsu_1"  -- Location MFSU2
  22. local mfsu3 = "mfsu_2"  -- Location MFSU3
  23. local mfsu4 = "mfsu_3"  -- Location MFSU4
  24. local mfsu5 = "mfsu_4"  -- Location MFSU5
  25. local mfsu6 = "mfsu_5"  -- Location MFSU6
  26. local mfsu7 = "mfsu_6"  -- Location MFSU7
  27. local mfsu8 = "mfsu_7"  -- Location MFSU8
  28. local mfsu9 = "mfsu_8"  -- Location MFSU9
  29.  
  30. local IsActive = "PlaceHolder" 
  31.  
  32. --computers that can send wireless signals
  33. local rc1 = rednet.lookup("rctrl","rc1")
  34. local rc2 = rednet.lookup("rctrl","rc2")
  35. local rc3 = rednet.lookup("rctrl","rc3")
  36. local rc4 = rednet.lookup("rctrl","rc4")
  37. local rc5 = rednet.lookup("rctrl","rc5")
  38. local rc6 = rednet.lookup("rctrl","rc6")
  39.  
  40. --computers that are under the reactors
  41. local rs1 = rednet.lookup("rctrl","rs1")
  42. local rs2 = rednet.lookup("rctrl","rs2")
  43. local rs3 = rednet.lookup("rctrl","rs3")
  44. local rs4 = rednet.lookup("rctrl","rs4")
  45. local rs5 = rednet.lookup("rctrl","rs5")
  46. local rs6 = rednet.lookup("rctrl","rs6")
  47.  
  48.  
  49. mfsu_1 = "mfsu_0"   -- Location MFSU1
  50. mfsu_2 = "mfsu_1"   -- Location MFSU2
  51. mfsu_3 = "mfsu_2"   -- Location MFSU3
  52. mfsu_4 = "mfsu_3"   -- Location MFSU4
  53. mfsu_5 = "mfsu_4"   -- Location MFSU5
  54. mfsu_6 = "mfsu_5"   -- Location MFSU6
  55. mfsu_7 = "mfsu_6"   -- Location MFSU7
  56. mfsu_8 = "mfsu_7"   -- Location MFSU8
  57. mfsu_9 = "mfsu_8"   -- Location MFSU9
  58.  
  59. R1OnOff = "Off"
  60. R2OnOff = "Off"
  61. R3OnOff = "Off"
  62. R4OnOff = "Off"
  63. R5OnOff = "Off"
  64. R6OnOff = "Off"
  65.  
  66. mfsu1 = peripheral.wrap(mfsu_1)
  67. mfsu2 = peripheral.wrap(mfsu_2)
  68. mfsu3 = peripheral.wrap(mfsu_3)
  69. mfsu4 = peripheral.wrap(mfsu_4)
  70. mfsu5 = peripheral.wrap(mfsu_5)
  71. mfsu6 = peripheral.wrap(mfsu_6)
  72. mfsu7 = peripheral.wrap(mfsu_7)
  73. mfsu8 = peripheral.wrap(mfsu_8)
  74. mfsu9 = peripheral.wrap(mfsu_9)
  75.  
  76. function mfsuAll()
  77.     while true do
  78.         mfsu1EUS = mfsu1.getEUStored()
  79.         mfsu2EUS = mfsu2.getEUStored()
  80.         mfsu3EUS = mfsu3.getEUStored()
  81.         mfsu4EUS = mfsu4.getEUStored()
  82.         mfsu5EUS = mfsu5.getEUStored()
  83.         mfsu6EUS = mfsu6.getEUStored()
  84.         mfsu7EUS = mfsu7.getEUStored()
  85.         mfsu8EUS = mfsu8.getEUStored()
  86.         mfsu9EUS = mfsu9.getEUStored()
  87.        
  88.         m.setCursorPos(45,15)
  89.         m.write("Reactor group 1")
  90.         m.setCursorPos(45,16)
  91.         m.write("MFSU1: 40000000/"..mfsu1EUS)
  92.         m.setCursorPos(45,17)
  93.         m.write("MFSU2: 40000000/"..mfsu2EUS)
  94.         m.setCursorPos(45,18)
  95.         m.write("MFSU3: 40000000/"..mfsu3EUS)
  96.         m.setCursorPos(45,19)
  97.         m.write("Reactor group 2")
  98.         m.setCursorPos(45,20)
  99.         m.write("MFSU4: 40000000/"..mfsu4EUS)
  100.         m.setCursorPos(45,21)
  101.         m.write("MFSU5: 40000000/"..mfsu5EUS)
  102.         m.setCursorPos(45,22)
  103.         m.write("MFSU6: 40000000/"..mfsu6EUS)
  104.         m.setCursorPos(45,23)
  105.         m.write("Reactor group 3")
  106.         m.setCursorPos(45,24)
  107.         m.write("MFSU7: 40000000/"..mfsu7EUS)
  108.         m.setCursorPos(45,25)
  109.         m.write("MFSU8: 40000000/"..mfsu8EUS)
  110.         m.setCursorPos(45,26)
  111.         m.write("MFSU9: 40000000/"..mfsu9EUS)
  112.         sleep(1)
  113.     end
  114. end
  115.  
  116. function LiquidTanksAll()
  117.     tank1 = peripheral.wrap(rfp1)
  118.     tank2 = peripheral.wrap(rfp2)
  119.     tank3 = peripheral.wrap(rfp3)
  120.     tank4 = peripheral.wrap(rfp4)
  121.     tank5 = peripheral.wrap(rfp5)
  122.     tank6 = peripheral.wrap(rfp6)
  123.  
  124.     EmptyCounter1 = 0
  125.     EmptyCounter2 = 0
  126.     EmptyCounter3 = 0
  127.     EmptyCounter4 = 0
  128.     EmptyCounter5 = 0
  129.     EmptyCounter6 = 0
  130.    
  131.     while true do
  132.         m.setCursorPos(45,1)
  133.         tank1I = tank1.getTankInfo()
  134.         tank2I = tank2.getTankInfo()
  135.         tank3I = tank3.getTankInfo()
  136.         tank4I = tank4.getTankInfo()
  137.         tank5I = tank5.getTankInfo()
  138.         tank6I = tank6.getTankInfo()
  139.  
  140. -- begin Reactor 1
  141.         if tank1I[1]["contents"] == nil then
  142.             EmptyCounter1 = EmptyCounter1 + 1
  143.             ic2c1ValueC = "0"
  144.         else
  145.             EmptyCounter1 = 0
  146.             if tank1I[1]["contents"]["name"] == "ic2coolant" then
  147.                 ic2c1 = tank1I[1]
  148.                 ic2c1ValueC = ic2c1["contents"]["amount"]
  149.             elseif tank1I[1]["contents"]["name"] == "ic2hotcoolant" then
  150.                 ic2hc1 = tank1I[1]
  151.                 ic2hc1ValueC = ic2hc1["contents"]["amount"]
  152.             else
  153.                 error("R1 Incorrect liquid in "..tank1I[1]["contents"]["name"])
  154.             end
  155.             if tank1I[2]["contents"] ~= nil then
  156.                 if tank1I[2]["contents"]["name"] == "ic2coolant" then
  157.                     ic2c1 = tank1I[2]
  158.                     ic2c1ValueC = ic2c1["contents"]["amount"]
  159.                 elseif tank1I[2]["contents"]["name"] == "ic2hotcoolant" then
  160.                     ic2hc1 = tank1I[2]
  161.                     ic2hc1ValueC = ic2hc1["contents"]["amount"]
  162.                 else
  163.                     error("R1 Incorrect liquid in "..tank1I[1]["contents"]["name"])
  164.                 end
  165.             else
  166.                 ic2hc1ValueC = "0"
  167.             end
  168.            
  169.             x1 = ic2c1ValueC / 10000 * 100
  170.             if x1 < 50 then
  171.                 m.setCursorPos(45,2)
  172.                 m.write("R1 warning!! Coolant level below :"..math.floor(x1).."% full.....")
  173.             else
  174.                 m.setCursorPos(45,2)
  175.                 m.write("R1 Coolant level is :"..math.floor(x1).."% full")
  176.             end
  177.             y1 = ic2hc1ValueC / 10000 * 100
  178.             if y1 > 50 then
  179.                 m.setCursorPos(45,3)
  180.                 m.write("R1 warning!! Hot Coolant level above :"..math.floor(y1).."% full.....")
  181.             else
  182.                 m.setCursorPos(45,3)
  183. --              m.write("R1 Hot Coolant level is :"..math.floor(y1).."% full")
  184.                 m.write("R1 Hot Coolant level is :"..ic2hc1ValueC.." full.....")
  185.             end
  186. --          sleep(0.5)
  187.         end
  188. -- end Reactor 1
  189. -- begin Reactor 2
  190.         if tank2I[1]["contents"] == nil then
  191.             EmptyCounter2 = EmptyCounter2 + 1
  192.             ic2c2ValueC = "0"
  193.         else
  194.             EmptyCounter2 = 0
  195.             if tank2I[1]["contents"]["name"] == "ic2coolant" then
  196.                 ic2c2 = tank2I[1]
  197.                 ic2c2ValueC = ic2c2["contents"]["amount"]
  198.             elseif tank2I[1]["contents"]["name"] == "ic2hotcoolant" then
  199.                 ic2hc2 = tank2I[1]
  200.                 ic2hc2ValueC = ic2hc2["contents"]["amount"]
  201.             else
  202.                 error("R2 Incorrect liquid in "..tank2I[1]["contents"]["name"])
  203.             end
  204.             if tank2I[2]["contents"] ~= nil then
  205.                 if tank2I[2]["contents"]["name"] == "ic2coolant" then
  206.                     ic2c2 = tank2I[2]
  207.                     ic2c2ValueC = ic2c2["contents"]["amount"]
  208.                 elseif tank2I[2]["contents"]["name"] == "ic2hotcoolant" then
  209.                     ic2hc2 = tank2I[2]
  210.                     ic2hc2ValueC = ic2hc2["contents"]["amount"]
  211.                 else
  212.                     error("R2 Incorrect liquid in "..tank2I[1]["contents"]["name"])
  213.                 end
  214.             else
  215.                 ic2hc2ValueC = "0"
  216.             end
  217.            
  218.             x2 = ic2c2ValueC / 10000 * 100
  219.             if x2 < 50 then
  220.                 m.setCursorPos(45,4)
  221.                 m.write("R2 warning!! Coolant level below :"..math.floor(x2).."% full.....")
  222.             else
  223.                 m.setCursorPos(45,4)
  224.                 m.write("R2 Coolant level is :"..math.floor(x2).."% full")
  225.             end
  226.             y2 = ic2hc2ValueC / 10000 * 100
  227.             if y2 > 50 then
  228.                 m.setCursorPos(45,5)
  229.                 m.write("R2 warning!! Hot Coolant level above :"..math.floor(y2).."% full.....")
  230.             else
  231.                 m.setCursorPos(45,5)
  232. --              m.write("R2 Hot Coolant level is :"..math.floor(y2).."% full")
  233.                 m.write("R2 Hot Coolant level is :"..ic2hc2ValueC.." full.....")
  234.             end
  235. --          sleep(0.5)
  236.         end
  237. -- end Reactor 2
  238. -- begin Reactor 3
  239.         if tank3I[1]["contents"] == nil then
  240.             EmptyCounter3 = EmptyCounter3 + 1
  241.             ic2c3ValueC = "0"
  242.         else
  243.             EmptyCounter3 = 0
  244.             if tank3I[1]["contents"]["name"] == "ic2coolant" then
  245.                 ic2c3 = tank3I[1]
  246.                 ic2c3ValueC = ic2c3["contents"]["amount"]
  247.             elseif tank3I[1]["contents"]["name"] == "ic2hotcoolant" then
  248.                 ic2hc3 = tank3I[1]
  249.                 ic2hc3ValueC = ic2hc3["contents"]["amount"]
  250.             else
  251.                 error("R3 Incorrect liquid in "..tank3I[1]["contents"]["name"])
  252.             end
  253.             if tank3I[2]["contents"] ~= nil then
  254.                 if tank3I[2]["contents"]["name"] == "ic2coolant" then
  255.                     ic2c3 = tank3I[2]
  256.                     ic2c3ValueC = ic2c3["contents"]["amount"]
  257.                 elseif tank3I[2]["contents"]["name"] == "ic2hotcoolant" then
  258.                     ic2hc3 = tank3I[2]
  259.                     ic2hc3ValueC = ic2hc3["contents"]["amount"]
  260.                 else
  261.                     error("R3 Incorrect liquid in "..tank3I[1]["contents"]["name"])
  262.                 end
  263.             else
  264.                 ic2hc3ValueC = "0"
  265.             end
  266.            
  267.             x3 = ic2c3ValueC / 10000 * 100
  268.             if x3 < 50 then
  269.                 m.setCursorPos(45,6)
  270.                 m.write("R3 warning!! Coolant level below :"..math.floor(x3).."% full.....")
  271.             else
  272.                 m.setCursorPos(45,6)
  273.                 m.write("R3 Coolant level is :"..math.floor(x3).."% full")
  274.             end
  275.             y3 = ic2hc3ValueC / 10000 * 100
  276.             if y3 > 50 then
  277.                 m.setCursorPos(45,7)
  278.                 m.write("R3 warning!! Hot Coolant level above :"..math.floor(y3).."% full.....")
  279.             else
  280.                 m.setCursorPos(45,7)
  281. --              m.write("R3 Hot Coolant level is :"..math.floor(y3).."% full")
  282.                 m.write("R3 Hot Coolant level is :"..ic2hc3ValueC.." full.....")
  283.             end
  284. --          sleep(0.5)
  285.         end
  286. -- end Reactor 3
  287. -- begin Reactor 4
  288.         if tank4I[1]["contents"] == nil then
  289.             EmptyCounter4 = EmptyCounter4 + 1
  290.             ic2c4ValueC = "0"
  291.         else
  292.             EmptyCounter4 = 0
  293.             if tank4I[1]["contents"]["name"] == "ic2coolant" then
  294.                 ic2c4 = tank4I[1]
  295.                 ic2c4ValueC = ic2c4["contents"]["amount"]
  296.             elseif tank4I[1]["contents"]["name"] == "ic2hotcoolant" then
  297.                 ic2hc4 = tank4I[1]
  298.                 ic2hc4ValueC = ic2hc4["contents"]["amount"]
  299.             else
  300.                 error("R4 Incorrect liquid in "..tank4I[1]["contents"]["name"])
  301.             end
  302.             if tank4I[2]["contents"] ~= nil then
  303.                 if tank4I[2]["contents"]["name"] == "ic2coolant" then
  304.                     ic2c4 = tank4I[2]
  305.                     ic2c4ValueC = ic2c4["contents"]["amount"]
  306.                 elseif tank4I[2]["contents"]["name"] == "ic2hotcoolant" then
  307.                     ic2hc4 = tank4I[2]
  308.                     ic2hc4ValueC = ic2hc4["contents"]["amount"]
  309.                 else
  310.                     error("R4 Incorrect liquid in "..tank4I[1]["contents"]["name"])
  311.                 end
  312.             else
  313.                 ic2hc4ValueC = "0"
  314.             end
  315.            
  316.             x4 = ic2c4ValueC / 10000 * 100
  317.             if x4 < 50 then
  318.                 m.setCursorPos(45,8)
  319.                 m.write("R4 warning!! Coolant level below :"..math.floor(x4).."% full.....")
  320.             else
  321.                 m.setCursorPos(45,8)
  322.                 m.write("R4 Coolant level is :"..math.floor(x4).."% full")
  323.             end
  324.             y4 = ic2hc4ValueC / 10000 * 100
  325.             if y4 > 50 then
  326.                 m.setCursorPos(45,9)
  327.                 m.write("R4 warning!! Hot Coolant level above :"..math.floor(y4).."% full.....")
  328.             else
  329.                 m.setCursorPos(45,9)
  330. --              m.write("R4 Hot Coolant level is :"..math.floor(y4).."% full")
  331.                 m.write("R4 Hot Coolant level is :"..ic2hc4ValueC.." full.....")
  332.             end
  333. --          sleep(0.5)
  334.         end
  335. -- end Reactor 4
  336. -- begin Reactor 5
  337.         if tank5I[1]["contents"] == nil then
  338.             EmptyCounter5 = EmptyCounter5 + 1
  339.             ic2c5ValueC = "0"
  340.         elseif tank5I[2] == nil then
  341.             EmptyCounter5 = EmptyCounter5 + 1
  342.         else
  343.             EmptyCounter5 = 0
  344.             if tank5I[1]["contents"]["name"] == "ic2coolant" then
  345.                 ic2c5 = tank5I[1]
  346.                 ic2c5ValueC = ic2c5["contents"]["amount"]
  347.             elseif tank5I[1]["contents"]["name"] == "ic2hotcoolant" then
  348.                 ic2hc5 = tank5I[1]
  349.                 ic2hc5ValueC = ic2hc5["contents"]["amount"]
  350.             else
  351.                 error("R5 Incorrect liquid in "..tank5I[1]["contents"]["name"])
  352.             end
  353.             if tank5I[2]["contents"] ~= nil then
  354.                 if tank5I[2]["contents"]["name"] == "ic2coolant" then
  355.                     ic2c5 = tank5I[2]
  356.                     ic2c5ValueC = ic2c5["contents"]["amount"]
  357.                 elseif tank5I[2]["contents"]["name"] == "ic2hotcoolant" then
  358.                     ic2hc5 = tank5I[2]
  359.                     ic2hc5ValueC = ic2hc5["contents"]["amount"]
  360.                 else
  361.                     error("R5 Incorrect liquid in "..tank5I[1]["contents"]["name"])
  362.                 end
  363.             else
  364.                 ic2hc5ValueC = "0"
  365.             end
  366.            
  367.             x5 = ic2c5ValueC / 10000 * 100
  368.             if x5 < 50 then
  369.                 m.setCursorPos(45,10)
  370.                 m.write("R5 warning!! Coolant level below :"..math.floor(x5).."% full.....")
  371.             else
  372.                 m.setCursorPos(45,10)
  373.                 m.write("R5 Coolant level is :"..math.floor(x5).."% full")
  374.             end
  375.             y5 = ic2hc5ValueC / 10000 * 100
  376.             if y5 > 50 then
  377.                 m.setCursorPos(45,11)
  378.                 m.write("R5 warning!! Hot Coolant level above :"..math.floor(y5).."% full.....")
  379.             else
  380.                 m.setCursorPos(45,11)
  381. --              m.write("R5 Hot Coolant level is :"..math.floor(y5).."% full")
  382.                 m.write("R5 Hot Coolant level is :"..ic2hc5ValueC.." full.....")
  383.             end
  384. --          sleep(0.5)
  385.         end
  386. -- end Reactor 5
  387. -- begin Reactor 6
  388.         if tank6I[1]["contents"] == nil then
  389.             EmptyCounter6 = EmptyCounter6 + 1
  390.             ic2c6ValueC = "0"
  391.         elseif tank6I[2] == nil then
  392.             EmptyCounter6 = EmptyCounter6 + 1
  393.         else
  394.             EmptyCounter6 = 0
  395.             if tank6I[1]["contents"]["name"] == "ic2coolant" then
  396.                 ic2c6 = tank6I[1]
  397.                 ic2c6ValueC = ic2c6["contents"]["amount"]
  398.             elseif tank6I[1]["contents"]["name"] == "ic2hotcoolant" then
  399.                 ic2hc6 = tank6I[1]
  400.                 ic2hc6ValueC = ic2hc6["contents"]["amount"]
  401.             else
  402.                 error("R6 Incorrect liquid in "..tank6I[1]["contents"]["name"])
  403.             end
  404.             if tank6I[2]["contents"] ~= nil then
  405.                 if tank6I[2]["contents"]["name"] == "ic2coolant" then
  406.                     ic2c6 = tank6I[2]
  407.                     ic2c6ValueC = ic2c6["contents"]["amount"]
  408.                 elseif tank6I[2]["contents"]["name"] == "ic2hotcoolant" then
  409.                     ic2hc6 = tank6I[2]
  410.                     ic2hc6ValueC = ic2hc6["contents"]["amount"]
  411.                 else
  412.                     error("R6 Incorrect liquid in "..tank6I[1]["contents"]["name"])
  413.                 end
  414.             else
  415.                 ic2hc6ValueC = "0"
  416.             end
  417.            
  418.             x6 = ic2c6ValueC / 10000 * 100
  419.             if x6 < 50 then
  420.                 m.setCursorPos(45,12)
  421.                 m.write("R6 warning!! Coolant level below :"..math.floor(x6).."% full.....")
  422.             else
  423.                 m.setCursorPos(45,12)
  424.                 m.write("R6 Coolant level is :"..math.floor(x6).."% full")
  425.             end
  426.             y6 = ic2hc6ValueC / 10000 * 100
  427.             if y6 > 50 then
  428.                 m.setCursorPos(45,13)
  429.                 m.write("R6 warning!! Hot Coolant level above :"..math.floor(61).."% full.....")
  430.             else
  431.                 m.setCursorPos(45,13)
  432. --              m.write("R6 Hot Coolant level is :"..math.floor(y6).."% full")
  433.                 m.write("R6 Hot Coolant level is :"..ic2hc6ValueC.." full.....")
  434.             end
  435. --          sleep(0.5)
  436.         end
  437.         sleep(1)
  438. -- end Reactor 6
  439.     end
  440. end
  441.  
  442. function fillTable()
  443.     button.setTable("Reactor1",Reactor1,2,15,2,4)
  444.     button.setTable("Reactor2",Reactor2,2,15,6,8)
  445.     button.setTable("Reactor3",Reactor3,2,15,10,12)
  446.     button.setTable("Reactor4",Reactor4,2,15,14,16)
  447.     button.setTable("Reactor5",Reactor5,2,15,18,20)
  448.     button.setTable("Reactor6",Reactor6,2,15,22,24)
  449.     button.setTable("Turn Off ALL",TurnOffALL,2,15,26,28)
  450.     button.screen()
  451. end
  452.  
  453.  
  454. function listen()
  455.     while true do
  456.         local senderIdL1, messageL1, protocolL1 = rednet.receive("rc1",3)
  457.         local senderIdL2, messageL2, protocolL2 = rednet.receive("rc2",3)
  458.         local senderIdL3, messageL3, protocolL3 = rednet.receive("rc3",3)
  459.         local senderIdL4, messageL4, protocolL4 = rednet.receive("rc4",3)
  460.         local senderIdL5, messageL5, protocolL5 = rednet.receive("rc5",3)
  461.         local senderIdL6, messageL6, protocolL6 = rednet.receive("rc6",3)
  462.        
  463.         if messageL1 ~= nil then
  464.             print("message from 1:"..messageL1)
  465.             R1OnOff = messageL1
  466.         else
  467.             print("Got no message from 1")
  468.         end
  469.         if messageL2 ~= nil then
  470.             print("message from 2:"..messageL2)
  471.             R2OnOff = messageL2
  472.         else
  473.             print("Got no message from 2")
  474.         end
  475.         if messageL3 ~= nil then
  476.             print("message from 3:"..messageL3)
  477.             R3OnOff = messageL3
  478.         else
  479.             print("Got no message from 3")
  480.         end
  481.         if messageL4 ~= nil then
  482.             print("message from 4:"..messageL4)
  483.             R4OnOff = messageL4
  484.         else
  485.             print("Got no message from 4")
  486.         end
  487.         if messageL5 ~= nil then
  488.             print("message from 5:"..messageL5)
  489.             R5OnOff = messageL5
  490.         else
  491.             print("Got no message from 5")
  492.         end
  493.         if messageL6 ~= nil then
  494.             print("message from 6:"..messageL6)
  495.             R6OnOff = messageL6
  496.         else
  497.             print("Got no message from 6")
  498.         end    
  499.    
  500.         sleep(0,5)
  501.     end
  502. end
  503.  
  504.  
  505. function urs()
  506. --Update Reactor status
  507. --  listenx = 1
  508.     while true do
  509. --      print("R1OnOff:"..R1OnOff)
  510. --      print("R2OnOff:"..R2OnOff)
  511. --      print("R3OnOff:"..R3OnOff)
  512. --      print("R4OnOff:"..R4OnOff)
  513. --      print("R5OnOff:"..R5OnOff)
  514. --      print("R6OnOff:"..R6OnOff)
  515.  
  516.         if R1OnOff == "Off" then
  517.             m.setBackgroundColor(colors.green)
  518.             m.setCursorPos(18,3) m.write("Off")
  519.             m.setBackgroundColor(colors.black)
  520.         else
  521.             m.setBackgroundColor(colors.red)
  522.             m.setCursorPos(18,3) m.write("On ")
  523.             m.setBackgroundColor(colors.black)
  524.         end
  525.         if R2OnOff == "Off" then
  526.             m.setBackgroundColor(colors.green)
  527.             m.setCursorPos(18,7) m.write("Off")
  528.             m.setBackgroundColor(colors.black)
  529.         else
  530.             m.setBackgroundColor(colors.red)
  531.             m.setCursorPos(18,7) m.write("On ")
  532.             m.setBackgroundColor(colors.black)
  533.         end
  534.         if R3OnOff == "Off" then
  535.             m.setBackgroundColor(colors.green)
  536.             m.setCursorPos(18,11) m.write("Off")
  537.             m.setBackgroundColor(colors.black)
  538.         else
  539.             m.setBackgroundColor(colors.red)
  540.             m.setCursorPos(18,11) m.write("On ")
  541.             m.setBackgroundColor(colors.black)
  542.         end
  543.         if R4OnOff == "Off" then
  544.             m.setBackgroundColor(colors.green)
  545.             m.setCursorPos(18,15) m.write("Off")
  546.             m.setBackgroundColor(colors.black)
  547.         else
  548.             m.setBackgroundColor(colors.red)
  549.             m.setCursorPos(18,15) m.write("On ")
  550.             m.setBackgroundColor(colors.black)
  551.         end
  552.         if R5OnOff == "Off" then
  553.             m.setBackgroundColor(colors.green)
  554.             m.setCursorPos(18,19) m.write("Off")
  555.             m.setBackgroundColor(colors.black)
  556.         else
  557.             m.setBackgroundColor(colors.red)
  558.             m.setCursorPos(18,19) m.write("On ")
  559.             m.setBackgroundColor(colors.black)
  560.         end
  561.         if R6OnOff == "Off" then
  562.             m.setBackgroundColor(colors.green)
  563.             m.setCursorPos(18,23) m.write("Off")
  564.             m.setBackgroundColor(colors.black)
  565.         else
  566.             m.setBackgroundColor(colors.red)
  567.             m.setCursorPos(18,23) m.write("On ")
  568.             m.setBackgroundColor(colors.black)
  569.         end
  570.         sleep(0,5)
  571. --      listenx = listenx + 1  
  572.     end
  573. end
  574.  
  575. function R1On()
  576.     print("Button 1 doet niets")
  577. end
  578.  
  579. function R2On()
  580.     print("Button 2 doet niets")
  581. end
  582.  
  583. function R3On()
  584.     print("Button 3 doet niets")
  585. end
  586.  
  587. function R4On()
  588.     print("Button 4 doet niets")
  589. end
  590.  
  591. function R5On()
  592.     print("Button 5 doet niets")
  593. end
  594.  
  595. function R6On()
  596.     print("Button 6 doet niets")
  597. end
  598.  
  599. function getClick()
  600.     while true do
  601.         event,side,x,y = os.pullEvent("monitor_touch")
  602.         button.checkxy(x, y)
  603.     end
  604. end                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  605. function pulse()
  606.     redstone.setOutput("back", true)
  607.     sleep(0,5)
  608.     redstone.setOutput("back", false)
  609. end
  610.  
  611. function Reactor1()
  612.     rednet.send(rc1,"TOR1","rctrl")
  613.     button.flash("Reactor1")
  614. end
  615.  
  616. function Reactor2()
  617.     rednet.send(rc2,"TOR2","rctrl")
  618.     button.flash("Reactor2")
  619. end
  620.  
  621. function Reactor3()
  622.     rednet.send(rc3,"TOR3","rctrl")
  623.     button.flash("Reactor3")
  624. end
  625.  
  626. function Reactor4()
  627.     rednet.send(rc4,"TOR4","rctrl")
  628.     button.flash("Reactor4")
  629. end
  630.  
  631. function Reactor5()
  632.     rednet.send(rc5,"TOR5","rctrl")
  633.     button.flash("Reactor5")
  634. end
  635.  
  636. function Reactor6()
  637.     rednet.send(rc6,"TOR6","rctrl")
  638.     button.flash("Reactor6")
  639. end
  640.  
  641. function TurnOffALL()
  642.     Reactor1()
  643.     Reactor2()
  644.     Reactor3()
  645.     Reactor4()
  646.     Reactor5()
  647.     Reactor6()
  648. end
  649.  
  650. fillTable()
  651.  
  652. m.setCursorPos(45,14)
  653. m.write("------------------------------------------------------------")
  654.  
  655. x1=0
  656.  
  657. while true do
  658. --  x1=x1 + 1
  659.     parallel.waitForAny(urs, listen, getClick , LiquidTanksAll, mfsuAll)
  660.     print("sleep:"..x1)
  661.     sleep(0.5)
  662. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement