Advertisement
Macsmith

active reactor

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