Advertisement
Macsmith

pasive reactor

Oct 30th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.31 KB | None | 0 0
  1. --Big reactors pasive cooled reactor program
  2. local reactor = peripheral.wrap("BigReactors-Reactor_1")
  3. local mon = peripheral.wrap("top")
  4. local maxfuel = reactor.getFuelAmountMax()
  5. local autorod = 1
  6. local rod = reactor.getControlRodLevel(0)
  7. local x = 0
  8. local y = 0
  9.  
  10. local function main()
  11.   while true do
  12.     mon.clear()
  13.  
  14.     mon.setCursorPos(1,1)
  15.     mon.setTextColor(colors.white)
  16.     mon.write("Active:")
  17.     if reactor.getActive() then
  18.       mon.setBackgroundColor(colors.green)
  19.       mon.write(" True")
  20.     else
  21.       mon.setBackgroundColor(colors.red)
  22.       mon.setTextColor(colors.black)
  23.       mon.write(" False")
  24.     end
  25.     mon.setBackgroundColor(colors.black)
  26.  
  27.     mon.setCursorPos(1,2)
  28.     mon.setTextColor(colors.white)
  29.     mon.write("RF/t: ")
  30.     mon.setTextColor(colors.lime)
  31.     mon.write(math.floor(reactor.getEnergyProducedLastTick()))
  32.  
  33.     mon.setCursorPos(1,3)
  34.     mon.setTextColor(colors.white)
  35.     mon.write("RF Stored: ")
  36.     mon.setTextColor(colors.lime)
  37.     mon.write(math.floor(reactor.getEnergyStored()))
  38.  
  39.     mon.setCursorPos(1,4)
  40.     mon.setTextColor(colors.white)
  41.     mon.write("Control Rods: ")
  42.     mon.setTextColor(colors.lime)
  43.     mon.write(reactor.getControlRodLevel(0))
  44.     mon.write(" %")
  45.  
  46.     mon.setCursorPos(1,5)
  47.     mon.setTextColor(colors.white)
  48.     mon.write("Fuel BR: ")
  49.     mon.setTextColor(colors.lime)
  50.     mon.write(tostring(reactor.getFuelConsumedLastTick()))
  51.     mon.write(" mB/t")
  52.  
  53.     mon.setCursorPos(1,6)
  54.     mon.setTextColor(colors.white)
  55.     mon.write("Fuel Amount: ")
  56.     mon.setTextColor(colors.lime)
  57.     mon.write(reactor.getFuelAmount()*100/maxfuel)
  58.     mon.write(" %")
  59.  
  60.     mon.setCursorPos(1,7)
  61.     mon.setTextColor(colors.white)
  62.     mon.write("Waste Amount: ")
  63.     mon.setTextColor(colors.lime)
  64.     mon.write(reactor.getWasteAmount()*100/maxfuel)
  65.     mon.write(" %")
  66.  
  67.     mon.setCursorPos(1,8)
  68.     mon.setTextColor(colors.white)
  69.     mon.write("Core heat: ")
  70.     mon.setTextColor(colors.lime)
  71.     mon.write(math.floor(reactor.getFuelTemperature()))
  72.     mon.write(" C")
  73.  
  74.     mon.setCursorPos(1,9)
  75.     mon.setTextColor(colors.white)
  76.     mon.write("Casing heat: ")
  77.     mon.setTextColor(colors.lime)
  78.     mon.write(math.floor(reactor.getCasingTemperature()))
  79.     mon.write(" C")
  80.  
  81.     mon.setCursorPos(1,10)
  82.     mon.setTextColor(colors.white)
  83.     mon.write("Rod auto-adjust:")
  84.     if autorod > 0 then
  85.       mon.setBackgroundColor(colors.green)
  86.       mon.write(" True")
  87.       rod = math.ceil(reactor.getEnergyStored()/100000)
  88.       reactor.setAllControlRodLevels(rod)
  89.     else
  90.       mon.setBackgroundColor(colors.red)
  91.       mon.setTextColor(colors.black)
  92.       mon.write(" False")
  93.     end
  94.     mon.setBackgroundColor(colors.black)
  95.    
  96.     mon.setCursorPos(1,11)
  97.     mon.setTextColor(colors.white)
  98.     mon.write("Manual rod: ")
  99.     mon.setBackgroundColor(colors.white)
  100.     mon.setTextColor(colors.black)
  101.     mon.write("<->")
  102.     mon.setBackgroundColor(colors.black)
  103.     mon.setTextColor(colors.white)
  104.     mon.write(":")
  105.     mon.setBackgroundColor(colors.white)
  106.     mon.setTextColor(colors.black)
  107.     mon.write("<+>")
  108.     mon.setBackgroundColor(colors.black)
  109.    
  110.     mon.setCursorPos(1,12)
  111.     mon.setTextColor(colors.white)
  112.     mon.write("Fuel reactivity: ")
  113.     mon.setTextColor(colors.lime)
  114.     mon.write(math.floor(reactor.getFuelReactivity()))
  115.     mon.write("%")
  116.    
  117.    
  118.     if (x >= 9) and (x <= 14) and (y == 1) then
  119.       if reactor.getActive() then
  120.         reactor.setActive(false)
  121.       else
  122.         reactor.setActive(true)
  123.       end
  124.       x = 0
  125.       y = 0
  126.     end
  127.    
  128.     if (x >= 18) and (x <= 23) and (y == 10) then
  129.       if autorod == 0 then
  130.         autorod = 1
  131.       else
  132.         autorod = 0
  133.       end
  134.       x = 0
  135.       y = 0
  136.     end
  137.    
  138.     if autorod == 0 then
  139.       if (x >= 13) and (x <= 15) and (y == 11) then
  140.         rod = rod - 1
  141.         reactor.setAllControlRodLevels(rod)
  142.         x = 0
  143.         y = 0
  144.       end
  145.      
  146.       if (x >=17 ) and (x<= 19) and (y == 11) then
  147.         rod = rod + 1
  148.         reactor.setAllControlRodLevels(rod)
  149.         x = 0
  150.         y = 0
  151.       end
  152.     end
  153.            
  154.     sleep(1)
  155.    
  156.   end
  157. end
  158.  
  159.  
  160. local function touch()
  161.   while true do
  162.     _, _, x, y = os.pullEvent("monitor_touch")
  163.   end
  164. end
  165.  
  166. parallel.waitForAny(main,touch)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement