Advertisement
alecblaster

BigReactors Computercraft ControlSystem (Single)

Oct 22nd, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.75 KB | None | 0 0
  1.    
  2.  
  3.     screen = peripheral.wrap("monitor_0")
  4.      
  5.     reactor1 = peripheral.wrap("BigReactors-Reactor_0")
  6.      
  7.     fuelt1 = 0
  8.      
  9.     while true do
  10.      
  11.     Fuel1 = reactor1.getFuelAmount()
  12.     Waste1 = reactor1.getWasteAmount()
  13.     Max1 = reactor1.getFuelAmountMax()
  14.     Rods1 = reactor1.getControlRodLevel(0)
  15.     CasingTemp1 = math.floor(reactor1.getCasingTemperature())
  16.     FuelTemp1 = math.floor(reactor1.getFuelTemperature())
  17.     Battery1 = reactor1.getEnergyStored()
  18.     RFT1 = math.floor(reactor1.getEnergyProducedLastTick())
  19.      
  20.     Fuelpercent1 = math.floor((Fuel1/Max1)*100)
  21.     Wastepercent1 = math.floor((Waste1/Max1)*100)
  22.     Batterypercent1 = math.floor((Battery1/10000000)*100)
  23.      
  24.      
  25.  
  26.  
  27.      
  28.     if reactor1.getActive() == true then
  29.             active1 = 1
  30.     else
  31.             active1 = 0
  32.     end
  33.      
  34.  
  35.      
  36.      
  37.      
  38.      
  39.      
  40.     screen.setTextScale(1)
  41.  
  42.      
  43.          
  44.      
  45.     if active1 == 1 then
  46.      
  47.     if Fuelpercent1 > 70 then
  48.             screen.setBackgroundColor(32)
  49.     end
  50.     if Fuelpercent1 < 71 then
  51.             screen.setBackgroundColor(16)
  52.     end
  53.     if Fuelpercent1 < 41 then
  54.             screen.setBackgroundColor(2)
  55.     end
  56.     if Fuelpercent1 < 21 then
  57.             screen.setBackgroundColor(16384)
  58.     end
  59.      
  60.     screen.setCursorPos(1,1)
  61.     screen.write("                                       ")
  62.     screen.setCursorPos(1,2)
  63.     screen.write("                                       ")
  64.     screen.setCursorPos(1,3)
  65.     screen.write("                                       ")
  66.     screen.setCursorPos(1,4)
  67.     screen.write("                                       ")
  68.     screen.setCursorPos(1,5)
  69.     screen.write("                                       ")
  70.     screen.setCursorPos(1,6)
  71.     screen.write("                                       ")
  72.     screen.setCursorPos(1,7)
  73.     screen.write("                                       ")
  74.     screen.setCursorPos(1,8)
  75.     screen.write("                                       ")
  76.     screen.setCursorPos(1,9)
  77.     screen.write("                                       ")
  78.     screen.setCursorPos(1,10)
  79.     screen.write("                                       ")
  80.     screen.setCursorPos(1,11)
  81.     screen.write("                                       ")
  82.     screen.setCursorPos(1,12)
  83.     screen.write("                                       ")
  84.      
  85.      
  86.     screen.setCursorPos(1,1)
  87.     screen.write("________________Reactor________________")
  88.     screen.setCursorPos(1,3)
  89.     screen.write("Fuel:                "..Fuelpercent1.."%")
  90.     screen.setCursorPos(1,4)
  91.     screen.write("Waste:               "..Wastepercent1.."%")
  92.     screen.setCursorPos(1,5)
  93.     screen.write("Control Rods:        "..Rods1.."%")
  94.     screen.setCursorPos(1,6)
  95.     screen.write("Casing Temperature:  "..CasingTemp1.."C")
  96.     screen.setCursorPos(1,7)
  97.     screen.write("Fuel Temperature:    "..FuelTemp1.."C")
  98.     screen.setCursorPos(1,8)
  99.     screen.write("Producing:           "..RFT1.." RF/t")
  100.     screen.setCursorPos(1,9)
  101.     screen.write("Battery:             "..Battery1.." RF / "..Batterypercent1.."%")
  102.      
  103.     else
  104.      
  105.     screen.setBackgroundColor(32768)
  106.     screen.setCursorPos(1,1)
  107.     screen.write("                                       ")
  108.     screen.setCursorPos(1,2)
  109.     screen.write("                                       ")
  110.     screen.setCursorPos(1,3)
  111.     screen.write("                                       ")
  112.     screen.setCursorPos(1,4)
  113.     screen.write("                                       ")
  114.     screen.setCursorPos(1,5)
  115.     screen.write("                                       ")
  116.     screen.setCursorPos(1,6)
  117.     screen.write("                                       ")
  118.     screen.setCursorPos(1,7)
  119.     screen.write("                                       ")
  120.     screen.setCursorPos(1,8)
  121.     screen.write("                                       ")
  122.     screen.setCursorPos(1,9)
  123.     screen.write("                                       ")
  124.     screen.setCursorPos(1,10)
  125.     screen.write("                                       ")
  126.     screen.setCursorPos(1,11)
  127.     screen.write("                                       ")
  128.     screen.setCursorPos(1,12)
  129.     screen.write("                                       ")
  130.     screen.setCursorPos(1,1)
  131.     screen.write("________________Reactor________________")
  132.     screen.setCursorPos(17,4)
  133.     screen.setTextColor(16384)
  134.     screen.write("Disabled")
  135.     screen.setTextColor(1)
  136.     end
  137.      
  138.      
  139.      
  140.  
  141.      
  142.  
  143.      
  144.      
  145.      
  146.      
  147.      
  148.     if blink == 1 then
  149.     blink = 0
  150.      
  151.     if Fuelpercent1 == 0 then
  152.             if Fuelpercent2 == 0 then
  153.                     outoffuel = 3
  154.             else
  155.                     outoffuel = 1
  156.             end
  157.     end
  158.  
  159.      
  160.     if active1 == 0 then
  161.             if outoffuel == 3 then
  162.                     outoffuel = 2
  163.             end
  164.             if outoffuel == 1 then
  165.                     outoffuel = 0
  166.             end
  167.     end
  168.  
  169.      
  170.      
  171.     if outoffuel > 0 then
  172.      
  173.     screen.setBackgroundColor(1)
  174.     screen.setCursorPos(10,7)
  175.     screen.write("---------------------")
  176.     screen.setCursorPos(10,13)
  177.     screen.write("---------------------")
  178.      
  179.     screen.setCursorPos(10,8)
  180.     screen.write("---------------------")
  181.     screen.setCursorPos(10,9)
  182.     screen.write("---------------------")
  183.     screen.setCursorPos(10,10)
  184.     screen.write("---------------------")
  185.     screen.setCursorPos(10,11)
  186.     screen.write("---------------------")
  187.     screen.setCursorPos(10,12)
  188.     screen.write("---------------------")
  189.      
  190.      
  191.     screen.setCursorPos(16,8)
  192.             screen.setTextColor(16384)
  193.             screen.write("Wanrning")
  194.             screen.setTextColor(32768)
  195.      
  196.     if outoffuel == 3 then
  197.             screen.setCursorPos(14,10)
  198.             screen.write("Reactor")
  199.             screen.setCursorPos(22,10)
  200.             screen.write("1&2")
  201.             screen.setCursorPos(25,10)
  202.             screen.write("are")
  203.     else
  204.             screen.setCursorPos(15,10)
  205.             screen.write("Reactor")
  206.            
  207.             screen.setCursorPos(23,10)
  208.            
  209.             if outoffuel == 1 then
  210.                     screen.write("1")
  211.             else
  212.                     screen.write("2")
  213.            
  214.             screen.setCursorPos(25,10)
  215.             screen.write("is")
  216.             end
  217.     end
  218.      
  219.            
  220.     screen.setCursorPos(15,11)
  221.     screen.write("out")
  222.     screen.setCursorPos(19,11)
  223.     screen.write("of")
  224.     screen.setCursorPos(22,11)
  225.     screen.write("fuel.")
  226.     end
  227.      
  228.     else
  229.     blink = 1
  230.     end
  231.      
  232.      
  233.      
  234.  
  235.    
  236.     if Batterypercent1 >= 90 then
  237.             reactor1.setAllControlRodLevels(Batterypercent1)
  238.     end
  239.      
  240.      
  241.     sleep(0)
  242.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement