Advertisement
Guest User

Reaktorkontrolle Computercraft

a guest
Apr 25th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.99 KB | None | 0 0
  1. m = peripheral.wrap("monitor_7")
  2. m2 = peripheral.wrap("monitor_8")
  3. m3 = peripheral.wrap("monitor_9")
  4. m4 = peripheral.wrap("monitor_10")
  5. m5 = peripheral.wrap("monitor_11")
  6. cap1 = peripheral.wrap("mfsu_2")
  7. cap2 = peripheral.wrap("mfsu_3")
  8. cap3 = peripheral.wrap("mfsu_4")
  9. cap4 = peripheral.wrap("mfsu_5")
  10. cap5 = peripheral.wrap("mfsu_6")
  11. cap6 = peripheral.wrap("mfsu_7")
  12. r1 = peripheral.wrap("nuclear_reactor_12")
  13. r2 = peripheral.wrap("nuclear_reactor_13")
  14. r3 = peripheral.wrap("nuclear_reactor_14")
  15. r4 = peripheral.wrap("nuclear_reactor_15")
  16. r5 = peripheral.wrap("nuclear_reactor_16")
  17. r6 = peripheral.wrap("nuclear_reactor_17")
  18.  
  19. tableColors = {
  20.               [1] = "White",
  21.               [2] = "Orange",
  22.               [4] = "Magenta",
  23.               [8] = "LightBlue",
  24.               [16] = "Yellow",
  25.               [32] = "Lime",
  26.               [64] = "Pink",
  27.               [128] = "Gray",
  28.               [256] = "LightGrey",
  29.               [512] = "Cyan",
  30.               [1024] = "Purple",
  31.               [2048] = "Blue",
  32.               [4096] = "Brown",
  33.               [8192] = "Green",
  34.               [16384] = "Red",
  35.               [32768] = "Black"
  36.               }
  37.  
  38. tableColorsFull = {}
  39. colorString = "Kein weiterer String gesetzt"
  40.  
  41. function TestColorTable()
  42.  
  43.   for bits = 1, #tableColors do
  44.     bitter = (bit.band(rs.getBundledInput("right"), bit.blshift(1, bits)) ~=0)
  45.     tableColorsFull[bits] = bitter
  46.   end
  47.  
  48.   for colors = 1, #tableColors do
  49.     if tableColorsFull[colors] == true then
  50.       colorString = (" ,"..tableColors[colors])
  51.     end
  52.   end
  53.  
  54. end
  55.  
  56. function getSide()
  57.   shell.run("clear")
  58.   print("Before we begin:\n")
  59.   print("on which side is the bundled Cable?")
  60.   print("(top, bottom, left, right, back, front)\n")
  61.   sideCheck = tostring(string.lower(read()))
  62.   if sideCheck == "top" or sideCheck == "bottom" or sideCheck == "left" or sideCheck == "right" or sideCheck == "back" or sideCheck == "front" then
  63.     print("\nYou specified \""..sideCheck.."\" as bundled Cable side")
  64.     print("Is that correct? [Y/N]")
  65.     print("")
  66.     entryCheck = read()
  67.     if entryCheck == "Y" or entryCheck == "y" then
  68.       side = sideCheck
  69.       term.setTextColor(colors.green)
  70.       print("\nSuccessfully set \""..side.."\" as the active side!")
  71.       term.setTextColor(colors.white)
  72.       sleep(5)
  73.     elseif entryCheck == "N" or entryCheck == "n" then
  74.       term.setTextColor(colors.red)
  75.       print("\nSide was not set!")
  76.       term.setTextColor(colors.white)
  77.       print("")
  78.       print("PC is restarting in 5")
  79.       sleep(1)
  80.       print("PC is restarting in 4")
  81.       sleep(1)
  82.       print("PC is restarting in 3")
  83.       sleep(1)
  84.       print("PC is restarting in 2")
  85.       sleep(1)
  86.       print("PC is restarting in 1")
  87.       sleep(1)
  88.       print("PC is restarting in 0")
  89.       sleep(1)
  90.       os.reboot()
  91.     else
  92.       term.setTextColor(colors.red)
  93.       print("\nEntry was wrong!")
  94.       term.setTextColor(colors.white)
  95.       print("")
  96.       print("PC is restarting in 10 Seconds")
  97.       sleep(5)
  98.       print("PC is restarting in 5")
  99.       sleep(1)
  100.       print("PC is restarting in 4")
  101.       sleep(1)
  102.       print("PC is restarting in 3")
  103.       sleep(1)
  104.       print("PC is restarting in 2")
  105.       sleep(1)
  106.       print("PC is restarting in 1")
  107.       sleep(1)
  108.       print("PC is restarting in 0")
  109.       sleep(1)
  110.       os.reboot()
  111.     end
  112.   else
  113.     term.setTextColor(colors.red)
  114.     print("\nThe computer says NO to \""..sideCheck.."\"")
  115.     print("because \""..sideCheck.."\" it is not a valid side")
  116.     term.setTextColor(colors.white)
  117.     print("\nPC is restarting in 10 Seconds")
  118.     sleep(5)
  119.     print("PC is restarting in 5")
  120.     sleep(1)
  121.     print("PC is restarting in 4")
  122.     sleep(1)
  123.     print("PC is restarting in 3")
  124.     sleep(1)
  125.     print("PC is restarting in 2")
  126.     sleep(1)
  127.     print("PC is restarting in 1")
  128.     sleep(1)
  129.     print("PC is restarting in 0")
  130.     sleep(1)
  131.     os.reboot()
  132.   end
  133. end
  134.  
  135.  
  136. --[[function ExitDoor()
  137.   --Exit Inner Door: 8
  138.   --Exit Outer Door: 4
  139.   --Entry Inner Door: 2
  140.   --Entry Outer Door: 1
  141.   if rs.getBundledInput(side) == 4 or rs.getBundledInput("left") == 8 then
  142.     m.setCursorPos(1,3)
  143.     m.write("Exit DoubleDoorSystem Control:")
  144.     m.setCursorPos(1,4)
  145.     m.setTextColor(colors.red)
  146.     m.write("DoubleDoorSystem active!")
  147.     m.setTextColor(colors.white)
  148.     if rs.getBundledInput(side) == 8 then
  149.       m.setCursorPos(1,6)
  150.       m.setTextColor(colors.red)
  151.       m.write("Inner Door Open!")
  152.       m.setTextColor(colors.white)
  153.       m.setCursorPos(1,7)
  154.       m.setTextColor(colors.green)
  155.       m.write("Outer Door Closed!")
  156.       m.setTextColor(colors.white)
  157.     elseif rs.getBundledInput(side) == 4 then
  158.       m.setCursorPos(1,7)
  159.       m.setTextColor(colors.red)
  160.       m.write("Outer Door Open!")
  161.       m.setTextColor(colors.white)
  162.       m.setCursorPos(1,6)
  163.       m.setTextColor(colors.green)
  164.       m.write("Inner Door Closed!")
  165.       m.setTextColor(colors.white)
  166.     end
  167.   else
  168.     m.setCursorPos(1,3)
  169.     m.write("Exit DoubleDoorSystem Control:")
  170.     m.setCursorPos(1,4)
  171.     m.setTextColor(colors.green)
  172.     m.write("DoubleDoorSystem inactive!")
  173.     m.setTextColor(colors.white)
  174.     m.setCursorPos(1,6)
  175.     m.setTextColor(colors.green)
  176.     m.write("Inner Door Closed!")
  177.     m.setCursorPos(1,7)
  178.     m.write("Outer Door Closed!")
  179.     m.setTextColor(colors.white)
  180.   end
  181. end
  182.  
  183. function EntryDoor()
  184.   if rs.getBundledInput(side) == 1 or rs.getBundledInput("left") == 2 then
  185.     m.setCursorPos(1,9)
  186.     m.write("Entry DoubleDoorSystem Control:")
  187.     m.setCursorPos(1,10)
  188.     m.setTextColor(colors.red)
  189.     m.write("DoubleDoorSystem active!")
  190.     m.setTextColor(colors.white)
  191.     if rs.getBundledInput(side) == 2 then
  192.       m.setCursorPos(1,12)
  193.       m.setTextColor(colors.red)
  194.       m.write("Inner Door Open!")
  195.       m.setTextColor(colors.white)
  196.       m.setCursorPos(1,13)
  197.       m.setTextColor(colors.green)
  198.       m.write("Outer Door Closed!")
  199.       m.setTextColor(colors.white)
  200.     elseif rs.getBundledInput(side) == 1 then
  201.       m.setCursorPos(1,13)
  202.       m.setTextColor(colors.red)
  203.       m.write("Outer Door Open!")
  204.       m.setTextColor(colors.white)
  205.       m.setCursorPos(1,12)
  206.       m.setTextColor(colors.green)
  207.       m.write("Inner Door Closed!")
  208.       m.setTextColor(colors.white)
  209.     end
  210.   else
  211.     m.setCursorPos(1,9)
  212.     m.write("Entry DoubleDoorSystem Control:")
  213.     m.setCursorPos(1,10)
  214.     m.setTextColor(colors.green)
  215.     m.write("DoubleDoorSystem inactive!")
  216.     m.setTextColor(colors.white)
  217.     m.setCursorPos(1,12)
  218.     m.setTextColor(colors.green)
  219.     m.write("Inner Door Closed!")
  220.     m.setCursorPos(1,13)
  221.     m.write("Outer Door Closed!")
  222.     m.setTextColor(colors.white)
  223.   end
  224. end
  225. ]]
  226. function getHeatData()
  227.   r1Temp = tonumber(r1.getHeat())
  228.   r2Temp = tonumber(r2.getHeat())
  229.   r3Temp = tonumber(r3.getHeat())
  230.   r4Temp = tonumber(r4.getHeat())
  231.   r5Temp = tonumber(r5.getHeat())
  232.   r6Temp = tonumber(r6.getHeat())
  233. end
  234.  
  235. function getEnergyData()
  236.   r1EU = tonumber(r1.getEUOutput())
  237.   r2EU = tonumber(r2.getEUOutput())
  238.   r3EU = tonumber(r3.getEUOutput())
  239.   r4EU = tonumber(r4.getEUOutput())
  240.   r5EU = tonumber(r5.getEUOutput())
  241.   r6EU = tonumber(r6.getEUOutput())
  242. end
  243.  
  244. function getActivityData()
  245.  
  246.   r1Act = (r1EU > 0)
  247.   r2Act = (r2EU > 0)
  248.   r3Act = (r3EU > 0)
  249.   r4Act = (r4EU > 0)
  250.   r5Act = (r5EU > 0)
  251.   r6Act = (r6EU > 0)
  252.  
  253. end
  254.  
  255. function printActivityData()
  256.  
  257.   if r1Act then
  258.     m.setCursorPos(1,4)
  259.     m.write("Reactor 1 :")
  260.     m.setTextColor(colors.red)
  261.     m.setCursorPos(1,5)
  262.     m.write("Active")
  263.     m.setTextColor(colors.white)
  264.   else
  265.     m.setCursorPos(1,4)
  266.     m.write("Reactor 1 :")
  267.     m.setTextColor(colors.green)
  268.     m.setCursorPos(1,5)
  269.     m.write("Inactive")
  270.     m.setTextColor(colors.white)
  271.   end
  272.  
  273.   if r2Act then
  274.     m.setCursorPos(1,7)
  275.     m.write("Reactor 2 :")
  276.     m.setTextColor(colors.red)
  277.     m.setCursorPos(1,8)
  278.     m.write("Active")
  279.     m.setTextColor(colors.white)
  280.   else
  281.     m.setCursorPos(1,7)
  282.     m.write("Reactor 2 :")
  283.     m.setTextColor(colors.green)
  284.     m.setCursorPos(1,8)
  285.     m.write("Inactive")
  286.     m.setTextColor(colors.white)
  287.   end
  288.  
  289.   if r3Act then
  290.     m.setCursorPos(1,10)
  291.     m.write("Reactor 3 :")
  292.     m.setTextColor(colors.red)
  293.     m.setCursorPos(1,11)
  294.     m.write("Active")
  295.     m.setTextColor(colors.white)
  296.   else
  297.     m.setCursorPos(1,10)
  298.     m.write("Reactor 3 :")
  299.     m.setTextColor(colors.green)
  300.     m.setCursorPos(1,11)
  301.     m.write("Inactive")
  302.     m.setTextColor(colors.white)
  303.   end
  304.  
  305.   if r4Act then
  306.     m.setCursorPos(1,13)
  307.     m.write("Reactor 4 :")
  308.     m.setTextColor(colors.red)
  309.     m.setCursorPos(1,14)
  310.     m.write("Active")
  311.     m.setTextColor(colors.white)
  312.   else
  313.     m.setCursorPos(1,13)
  314.     m.write("Reactor 4 :")
  315.     m.setTextColor(colors.green)
  316.     m.setCursorPos(1,14)
  317.     m.write("Inactive")
  318.     m.setTextColor(colors.white)
  319.   end
  320.  
  321.   if r5Act then
  322.     m.setCursorPos(1,16)
  323.     m.write("Reactor 5 :")
  324.     m.setTextColor(colors.red)
  325.     m.setCursorPos(1,17)
  326.     m.write("Active")
  327.     m.setTextColor(colors.white)
  328.   else
  329.     m.setCursorPos(1,16)
  330.     m.write("Reactor 5 :")
  331.     m.setTextColor(colors.green)
  332.     m.setCursorPos(1,17)
  333.     m.write("Inactive")
  334.     m.setTextColor(colors.white)
  335.   end
  336.  
  337.   if r6Act then
  338.     m.setCursorPos(1,19)
  339.     m.write("Reactor 6 :")
  340.     m.setTextColor(colors.red)
  341.     m.setCursorPos(1,20)
  342.     m.write("Active")
  343.     m.setTextColor(colors.white)
  344.   else
  345.     m.setCursorPos(1,19)
  346.     m.write("Reactor 6 :")
  347.     m.setTextColor(colors.green)
  348.     m.setCursorPos(1,20)
  349.     m.write("Inactive")
  350.     m.setTextColor(colors.white)
  351.   end
  352.  
  353. end
  354.  
  355. function makeReactorEnergyColor()
  356.   if r1EU > 0 then
  357.     r1color = colors.red
  358.   else
  359.     r1color = colors.green
  360.   end
  361.  
  362.   if r2EU > 0 then
  363.     r2color = colors.red
  364.   else
  365.     r2color = colors.green
  366.   end
  367.  
  368.   if r3EU > 0 then
  369.     r3color = colors.red
  370.   else
  371.     r3color = colors.green
  372.   end
  373.  
  374.   if r4EU > 0 then
  375.     r4color = colors.red
  376.   else
  377.     r4color = colors.green
  378.   end
  379.  
  380.   if r5EU > 0 then
  381.     r5color = colors.red
  382.   else
  383.     r5color = colors.green
  384.   end
  385.  
  386.   if r6EU > 0 then
  387.     r6color = colors.red
  388.   else
  389.     r6color = colors.green
  390.   end
  391. end
  392.  
  393. function makeReactorHeatColor()
  394.   if r1Temp >= 0 and r1Temp <= 3000 then
  395.     r1TempColor = tonumber(8192)
  396.   elseif r1Temp > 3000 and r1Temp <= 5000 then
  397.     r1TempColor = tonumber(32)
  398.   elseif r1Temp > 5000 and r1Temp <= 7000 then
  399.     r1TempColor = tonumber(16)
  400.   elseif r1Temp > 7000 and r1Temp <= 9000 then
  401.     r1TempColor = tonumber(2)
  402.   else
  403.     r1TempColor = tonumber(16384)
  404.   end
  405.  
  406.   if r2Temp >= 0 and r2Temp <= 3000 then
  407.     r2TempColor = tonumber(8192)
  408.   elseif r2Temp > 3000 and r2Temp <= 5000 then
  409.     r2TempColor = tonumber(32)
  410.   elseif r2Temp > 5000 and r2Temp <= 7000 then
  411.     r2TempColor = tonumber(16)
  412.   elseif r2Temp > 7000 and r2Temp <= 9000 then
  413.     r2TempColor = tonumber(2)
  414.   else
  415.     r2TempColor = tonumber(16384)
  416.   end
  417.  
  418.   if r3Temp >= 0 and r3Temp <= 3000 then
  419.     r3TempColor = tonumber(8192)
  420.   elseif r3Temp > 3000 and r3Temp <= 5000 then
  421.     r3TempColor = tonumber(32)
  422.   elseif r3Temp > 5000 and r3Temp <= 7000 then
  423.     r3TempColor = tonumber(16)
  424.   elseif r3Temp > 7000 and r3Temp <= 9000 then
  425.     r3TempColor = tonumber(2)
  426.   else
  427.     r3TempColor = tonumber(16384)
  428.   end
  429.  
  430.   if r4Temp >= 0 and r4Temp <= 3000 then
  431.     r4TempColor = tonumber(8192)
  432.   elseif r1Temp > 3000 and r4Temp <= 5000 then
  433.     r4TempColor = tonumber(32)
  434.   elseif r1Temp > 5000 and r4Temp <= 7000 then
  435.     r4TempColor = tonumber(16)
  436.   elseif r1Temp > 7000 and r4Temp <= 9000 then
  437.     r4TempColor = tonumber(2)
  438.   else
  439.     r4TempColor = tonumber(16384)
  440.   end
  441.  
  442.   if r5Temp >= 0 and r5Temp <= 3000 then
  443.     r5TempColor = tonumber(8192)
  444.   elseif r1Temp > 3000 and r5Temp <= 5000 then
  445.     r5TempColor = tonumber(32)
  446.   elseif r1Temp > 5000 and r5Temp <= 7000 then
  447.     r5TempColor = tonumber(16)
  448.   elseif r1Temp > 7000 and r5Temp <= 9000 then
  449.     r5TempColor = tonumber(2)
  450.   else
  451.     r5TempColor = tonumber(16384)
  452.   end
  453.  
  454.   if r6Temp >= 0 and r6Temp <= 3000 then
  455.     r6TempColor = tonumber(8192)
  456.   elseif r1Temp > 3000 and r6Temp <= 5000 then
  457.     r6TempColor = tonumber(32)
  458.   elseif r1Temp > 5000 and r6Temp <= 7000 then
  459.     r6TempColor = tonumber(16)
  460.   elseif r1Temp > 7000 and r6Temp <= 9000 then
  461.     r6TempColor = tonumber(2)
  462.   else
  463.     r6TempColor = tonumber(16384)
  464.   end
  465. end
  466.  
  467. function printEnergyData()
  468.   m2.setTextColor(colors.white)
  469.   m2.setCursorPos(1,4)
  470.   m2.write("Reactor 1 Energy:")
  471.   m2.setCursorPos(1,5)
  472.   m2.setTextColor(r1color)
  473.   m2.write((r1EU*5).." EU/t")
  474.   m2.setTextColor(colors.white)
  475.   m2.setCursorPos(1,7)
  476.   m2.write("Reactor 2 Energy:")
  477.   m2.setCursorPos(1,8)
  478.   m2.setTextColor(r2color)
  479.   m2.write((r2EU*5).." EU/t")
  480.   m2.setTextColor(colors.white)
  481.   m2.setCursorPos(1,10)
  482.   m2.write("Reactor 3 Energy:")
  483.   m2.setCursorPos(1,11)
  484.   m2.setTextColor(r3color)
  485.   m2.write((r3EU*5).." EU/t")
  486.   m2.setTextColor(colors.white)
  487.   m2.setCursorPos(1,13)
  488.   m2.write("Reactor 4 Energy:")
  489.   m2.setCursorPos(1,14)
  490.   m2.setTextColor(r4color)
  491.   m2.write((r4EU*5).." EU/t")
  492.   m2.setTextColor(colors.white)
  493.   m2.setCursorPos(1,16)
  494.   m2.write("Reactor 5 Energy:")
  495.   m2.setCursorPos(1,17)
  496.   m2.setTextColor(r5color)
  497.   m2.write((r5EU*5).." EU/t")
  498.   m2.setTextColor(colors.white)
  499.   m2.setCursorPos(1,19)
  500.   m2.write("Reactor 6 Energy:")
  501.   m2.setCursorPos(1,20)
  502.   m2.setTextColor(r6color)
  503.   m2.write((r6EU*5).." EU/t")
  504.   m2.setTextColor(colors.white)
  505. end
  506.  
  507. function printHeatData()
  508.  
  509.   m4.setCursorPos(1,4)
  510.   m4.write("Temperature Reactor 1: ")
  511.   m4.setTextColor(r1TempColor)
  512.   m4.setCursorPos(1,5)
  513.   m4.write(r1Temp.." Deg.")
  514.   m4.setTextColor(colors.white)
  515.   m4.setCursorPos(1,7)
  516.   m4.write("Temperature Reactor 2: ")
  517.   m4.setTextColor(r2TempColor)
  518.   m4.setCursorPos(1,8)
  519.   m4.write(r2Temp.." Deg.")
  520.   m4.setTextColor(colors.white)
  521.   m4.setCursorPos(1,10)
  522.   m4.write("Temperature Reactor 3: ")
  523.   m4.setTextColor(r3TempColor)
  524.   m4.setCursorPos(1,11)
  525.   m4.write(r3Temp.." Deg.")
  526.   m4.setTextColor(colors.white)
  527.   m4.setCursorPos(1,13)
  528.   m4.write("Temperature Reactor 4: ")
  529.   m4.setTextColor(r4TempColor)
  530.   m4.setCursorPos(1,14)
  531.   m4.write(r4Temp.." Deg.")
  532.   m4.setTextColor(colors.white)
  533.   m4.setCursorPos(1,16)
  534.   m4.write("Temperature Reactor 5: ")
  535.   m4.setTextColor(r5TempColor)
  536.   m4.setCursorPos(1,17)
  537.   m4.write(r5Temp.." Deg.")
  538.   m4.setTextColor(colors.white)
  539.   m4.setCursorPos(1,19)
  540.   m4.write("Temperature Reactor 6: ")
  541.   m4.setTextColor(r6TempColor)
  542.   m4.setCursorPos(1,20)
  543.   m4.write(r6Temp.." Deg.")
  544.   m4.setTextColor(colors.white)
  545.  
  546. end
  547.  
  548. function getCapacitorData()
  549.   MaxEU1 = tonumber(cap1.getEUCapacity())
  550.   MaxEU2 = tonumber(cap2.getEUCapacity())
  551.   MaxEU3 = tonumber(cap1.getEUCapacity())
  552.   MaxEU4 = tonumber(cap2.getEUCapacity())
  553.   MaxEU5 = tonumber(cap1.getEUCapacity())
  554.   MaxEU6 = tonumber(cap2.getEUCapacity())
  555.   EU1 = tonumber(cap1.getEUStored())
  556.   EU2 = tonumber(cap2.getEUStored())
  557.   EU3 = tonumber(cap1.getEUStored())
  558.   EU4 = tonumber(cap2.getEUStored())
  559.   EU5 = tonumber(cap1.getEUStored())
  560.   EU6 = tonumber(cap2.getEUStored())
  561. end
  562.  
  563. function format_thousand(v)
  564.   local s = string.format("%d", math.floor(v))
  565.   local pos = string.len(s) % 3
  566.   if pos == 0 then pos = 3 end
  567.   return string.sub(s, 1, pos)
  568.     .. string.gsub(string.sub(s, pos+1), "(...)", ",%1")
  569.     .. string.sub(string.format("%.2f", v - math.floor(v)), 2)
  570. end
  571.  
  572. function makeMFSUColor()
  573.  
  574.   if EU1 >= 0 and EU1 <= 10000000 then
  575.     MFSU1Color = colors.green
  576.   elseif EU1 > 10000000 and EU1 <= 25000000 then
  577.     MFSU1Color = colors.lime
  578.   elseif EU1 > 25000000 and EU1 <= 35000000 then
  579.     MFSU1Color = colors.yellow
  580.   elseif EU1 > 35000000 and EU1 < 40000000 then
  581.     MFSU1Color = colors.orange
  582.   else
  583.     MFSU1Color = colors.red
  584.   end
  585.  
  586.   if EU2 >= 0 and EU2 <= 10000000 then
  587.     MFSU2Color = colors.green
  588.   elseif EU2 > 10000000 and EU2 <= 25000000 then
  589.     MFSU2Color = colors.lime
  590.   elseif EU2 > 25000000 and EU2 <= 35000000 then
  591.     MFSU2Color = colors.yellow
  592.   elseif EU2 > 35000000 and EU2 < 40000000 then
  593.     MFSU2Color = colors.orange
  594.   else
  595.     MFSU2Color = colors.red
  596.   end
  597.  
  598.   if EU3 >= 0 and EU3 <= 10000000 then
  599.     MFSU3Color = colors.green
  600.   elseif EU3 > 10000000 and EU3 <= 25000000 then
  601.     MFSU3Color = colors.lime
  602.   elseif EU3 > 25000000 and EU3 <= 35000000 then
  603.     MFSU3Color = colors.yellow
  604.   elseif EU3 > 35000000 and EU3 < 40000000 then
  605.     MFSU3Color = colors.orange
  606.   else
  607.     MFSU3Color = colors.red
  608.   end
  609.  
  610.   if EU4 >= 0 and EU4 <= 10000000 then
  611.     MFSU4Color = colors.green
  612.   elseif EU4 > 10000000 and EU4 <= 25000000 then
  613.     MFSU4Color = colors.lime
  614.   elseif EU4 > 25000000 and EU4 <= 35000000 then
  615.     MFSU4Color = colors.yellow
  616.   elseif EU4 > 35000000 and EU4 < 40000000 then
  617.     MFSU4Color = colors.orange
  618.   else
  619.     MFSU4Color = colors.red
  620.   end
  621.  
  622.   if EU5 >= 0 and EU5 <= 10000000 then
  623.     MFSU5Color = colors.green
  624.   elseif EU5 > 10000000 and EU5 <= 25000000 then
  625.     MFSU5Color = colors.lime
  626.   elseif EU5 > 25000000 and EU5 <= 35000000 then
  627.     MFSU5Color = colors.yellow
  628.   elseif EU5 > 35000000 and EU5 < 40000000 then
  629.     MFSU5Color = colors.orange
  630.   else
  631.     MFSU5Color = colors.red
  632.   end
  633.  
  634.   if EU6 >= 0 and EU6 <= 10000000 then
  635.     MFSU6Color = colors.green
  636.   elseif EU6 > 10000000 and EU6 <= 25000000 then
  637.     MFSU6Color = colors.lime
  638.   elseif EU6 > 25000000 and EU6 <= 35000000 then
  639.     MFSU6Color = colors.yellow
  640.   elseif EU6 > 35000000 and EU6 < 40000000 then
  641.     MFSU6Color = colors.orange
  642.   else
  643.     MFSU6Color = colors.red
  644.   end
  645.  
  646. end
  647.  
  648. function printCapacitorData()
  649.  
  650.   m3.setCursorPos(1,4)
  651.   m3.setTextColor(colors.white)
  652.   m3.write("MFSU 1:")
  653.   m3.setCursorPos(1,5)
  654.   m3.setTextColor(MFSU1Color)
  655.   m3.write(format_thousand(EU1).."/"..format_thousand(MaxEU1))
  656.  
  657.   m3.setCursorPos(1,7)
  658.   m3.setTextColor(colors.white)
  659.   m3.write("MFSU 2:")
  660.   m3.setCursorPos(1,8)
  661.   m3.setTextColor(MFSU1Color)
  662.   m3.write(format_thousand(EU2).."/"..format_thousand(MaxEU2))
  663.  
  664.   m3.setCursorPos(1,10)
  665.   m3.setTextColor(colors.white)
  666.   m3.write("MFSU 3:")
  667.   m3.setCursorPos(1,11)
  668.   m3.setTextColor(MFSU1Color)
  669.   m3.write(format_thousand(EU3).."/"..format_thousand(MaxEU3))
  670.  
  671.   m3.setCursorPos(1,13)
  672.   m3.setTextColor(colors.white)
  673.   m3.write("MFSU 4:")
  674.   m3.setCursorPos(1,14)
  675.   m3.setTextColor(MFSU1Color)
  676.   m3.write(format_thousand(EU4).."/"..format_thousand(MaxEU4))
  677.  
  678.   m3.setCursorPos(1,16)
  679.   m3.setTextColor(colors.white)
  680.   m3.write("MFSU 5:")
  681.   m3.setCursorPos(1,17)
  682.   m3.setTextColor(MFSU1Color)
  683.   m3.write(format_thousand(EU5).."/"..format_thousand(MaxEU5))
  684.  
  685.   m3.setCursorPos(1,19)
  686.   m3.setTextColor(colors.white)
  687.   m3.write("MFSU 6:")
  688.   m3.setCursorPos(1,20)
  689.   m3.setTextColor(MFSU1Color)
  690.   m3.write(format_thousand(EU6).."/"..format_thousand(MaxEU6))
  691.  
  692. end
  693.  
  694. function emergencyStop()
  695.   if r1Temp > 8000 or r2Temp > 8000 or r3Temp > 8000 or r4Temp > 8000 or r5Temp > 8000 or r6Temp > 8000 then
  696.     rs.setBundledOutput(side, colors.red)
  697.   end
  698. end
  699.  
  700. function getEmergencyStopStatus()
  701.   getTime = os.time()
  702.   time = textutils.formatTime(getTime, false)
  703.   if rs.getBundledInput(side) == colors.black then
  704.     emergencyStopStatus = "STOPPED"
  705.     statusColor = colors.red
  706.     ok = false
  707.   elseif rs.getBundledInput(side) == colors.green then
  708.     emergencyStopStatus = "OK"
  709.     statusColor = colors.green
  710.     ok = true
  711.   elseif rs.getBundledInput(side) == colors.red then
  712.     rs.setBundledOutput(side, 0)
  713.     ok = false
  714.   else
  715.     print("Something went wrong!")
  716.    
  717.   end
  718.   return ok
  719. end
  720.  
  721. function printEmergencyStop()
  722.   m.setCursorPos(1,22)
  723.   m2.setCursorPos(1,22)
  724.   m3.setCursorPos(1,22)
  725.   m4.setCursorPos(1,22)
  726.   m5.setCursorPos(1,22)
  727.  
  728.   m.write(time..": Status, ")
  729.   m.setTextColor(statusColor)
  730.   m.write(emergencyStopStatus)
  731.   m.setTextColor(colors.white)
  732.  
  733.   m2.write(time..": Status, ")
  734.   m2.setTextColor(statusColor)
  735.   m2.write(emergencyStopStatus)
  736.   m2.setTextColor(colors.white)
  737.  
  738.   m3.write(time..": Status, ")
  739.   m3.setTextColor(statusColor)
  740.   m3.write(emergencyStopStatus)
  741.   m3.setTextColor(colors.white)
  742.  
  743.   m4.write(time..": Status, ")
  744.   m4.setTextColor(statusColor)
  745.   m4.write(emergencyStopStatus)
  746.   m4.setTextColor(colors.white)
  747.  
  748.   m5.write(time..": Status, ")
  749.   m5.setTextColor(statusColor)
  750.   m5.write(emergencyStopStatus)
  751.   m5.setTextColor(colors.white)
  752. end
  753.  
  754. function getData()
  755.   getHeatData()
  756.   getEnergyData()
  757.   getActivityData()
  758.   getCapacitorData()
  759. end
  760.  
  761. function printData()
  762.   --ExitDoor()
  763.   --EntryDoor()
  764.   printHeatData()
  765.   printEnergyData()
  766.   printActivityData()
  767.   printCapacitorData()
  768. end
  769.  
  770. function color()
  771.   makeReactorEnergyColor()
  772.   makeReactorHeatColor()
  773.   makeMFSUColor()
  774. end
  775.  
  776. function testEmergencyStop()
  777.   r1Temp = r1Temp + 200
  778. end
  779.  
  780. getSide()
  781. --r1Temp = 0
  782.  
  783. while true do
  784.   getData()
  785.   emergencyStop()
  786.   getEmergencyStopStatus()
  787.   if ok == true then
  788.     m.clear()
  789.     m2.clear()
  790.     m3.clear()
  791.     m4.clear()
  792.     m5.clear()
  793.     m.setTextScale(1.5)
  794.     m2.setTextScale(1.5)
  795.     m3.setTextScale(1.5)
  796.     m4.setTextScale(1.5)
  797.     m5.setTextScale(1.5)
  798.     m.setCursorPos(1,1)
  799.     m2.setCursorPos(1,1)
  800.     m3.setCursorPos(1,1)
  801.     m4.setCursorPos(1,1)
  802.     m5.setCursorPos(1,1)
  803.     m.setTextColor(colors.white)
  804.     m2.setTextColor(colors.white)
  805.     m3.setTextColor(colors.white)
  806.     m4.setTextColor(colors.white)
  807.     m5.setTextColor(colors.white)
  808.     m.write("Nuclear Control:")
  809.     m2.write("Energy Overview Reactors:")
  810.     m3.write("Energy Overview MFSU:")
  811.     m4.write("Temperature Overview:")
  812.     m5.write("Door Control:")
  813.     m5.setCursorPos(1,4)
  814.     m5.write("Not yet implemented")
  815.     m5.setCursorPos(1,5)
  816.     m5.write("Coming soon!")
  817.     getData()
  818.     --testEmergencyStop()
  819.     color()
  820.     printEmergencyStop()
  821.     printData()
  822.     sleep(0.2)
  823.     shell.run("clear")
  824.     print("Emergencystop Status: "..emergencyStopStatus)
  825.     print("It is "..time)
  826.     print("Redstone side is: "..side)
  827.     TestColorTable()
  828.     print(colorString)
  829.   else
  830.     getEmergencyStopStatus()
  831.     printEmergencyStop()
  832.   end
  833. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement