Advertisement
Guest User

startup

a guest
Apr 27th, 2021
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.54 KB | None | 0 0
  1. local monitor = peripheral.wrap("monitor_1")
  2. local capacitor = peripheral.wrap("tile_blockcapacitorbank_name_1")
  3. local reactor = peripheral.wrap("BigReactors-Reactor_0")
  4. local turbine_1 = peripheral.wrap("BigReactors-Turbine_0")
  5. local turbine_2 = peripheral.wrap("BigReactors-Turbine_1")
  6.  
  7. monitor.setTextColor(1)
  8. monitor.setBackgroundColor(128)
  9. monitor.clear()
  10. local width, height = monitor.getSize()
  11. print("Monitor size: Columns:"..width..", Rows:"..height)
  12.  
  13. makePercent = 100
  14. capacitorCount = 56
  15. capacitorBasic = 1000000
  16. capacitorStandard = 5000000
  17. capacitorVibrant = 25000000
  18. totalCapacity = (capacitorCount) * (capacitorVibrant)
  19.  
  20. reactorRunning = false
  21. reactor.setActive(false)
  22.  
  23.  
  24. while true do
  25.   capacitorLevel = capacitor.getEnergyStored()
  26.   capacitorAdjusted = (capacitorLevel) * (capacitorCount)
  27.   capacitorFillPct = ((capacitorAdjusted) / (totalCapacity)) * (100)
  28.   capacitorInt = math.floor(capacitorFillPct)
  29.  
  30.   reactorCasingTemp = math.floor(reactor.getCasingTemperature())
  31.   reactorRodLevel = reactor.getControlRodLevel(1)
  32.  
  33.   turbineSpeed_1 = math.floor(turbine_1.getRotorSpeed())
  34.   turbineSpeed_2 = math.floor(turbine_2.getRotorSpeed())
  35.  
  36.   if (capacitorFillPct < 30) and (reactorRunning == false) then
  37.     reactorRunning = true
  38.   elseif (capacitorFillPct >=99) and (reactorRunning == true) then
  39.     reactorRunning = false
  40.   end
  41.  
  42.   if reactorRunning == true then
  43.     reactor.setActive(true)
  44.     if reactor.getActive() == false then
  45.       reactor.setActive(true)
  46.     end
  47.     if reactorCasingTemp < 720 and (reactorRodLevel ~= 0) then
  48.       reactor.setAllControlRodLevels(0)
  49.     elseif (reactorCasingTemp >= 720) and (reactorRodLevel ~= 80) then
  50.       reactor.setAllControlRodLevels(60)
  51.     end
  52.     if (reactorCasingTemp >= 720) then
  53.       if (turbineSpeed_1 < 1780) and (turbine_1.getFluidFlowRateMax() ~= 2000) then
  54.         turbine_1.setFluidFlowRateMax(2000)
  55.       end
  56.       if (turbineSpeed_2 < 1780) and (turbine_2.getFluidFlowRateMax() ~= 2000) then
  57.         turbine_2.setFluidFlowRateMax(2000)
  58.       end
  59.       if (turbineSpeed_1 > 1780) and (turbineSpeed_1 <= 1850) and (turbine_1.getFluidFlowRateMax() ~= 2000) then
  60.         turbine_1.setFluidFlowRateMax(2000)
  61.         turbine_1.setInductorEngaged(true)
  62.       end
  63.       if (turbineSpeed_2 > 1780) and (turbineSpeed_2 <= 1850) and (turbine_2.getFluidFlowRateMax() ~= 2000) then
  64.         turbine_2.setFluidFlowRateMax(2000)
  65.         turbine_2.setInductorEngaged(true)
  66.       end
  67.       if (turbineSpeed_1 > 1850) and (turbine_1.getFluidFlowRateMax() ~= 0) then
  68.         turbine_1.setFluidFlowRateMax(0)
  69.       end
  70.       if (turbineSpeed_2 > 1850) and (turbine_2.getFluidFlowRateMax() ~= 0) then
  71.         turbine_2.setFluidFlowRateMax(0)
  72.       end
  73.     end
  74.   end
  75.  
  76.   if reactorRunning == false then
  77.     reactor.setActive(false)
  78.     if reactor.getActive == true then
  79.       reactor.setActive(false)
  80.     end
  81.     if turbine_1.getFluidFlowRateMax() ~= 0 then
  82.       turbine_1.setFluidFlowRateMax(0)
  83.     end
  84.     if turbine_1.getInductorEngaged() ~= false then
  85.       turbine_1.setInductorEngaged(false)
  86.     end
  87.     if turbine_2.getFluidFlowRateMax() ~= 0 then
  88.       turbine_2.setFluidFlowRateMax(0)
  89.     end
  90.     if turbine_2.getInductorEngaged() ~= false then
  91.       turbine_2.setInductorEngaged(false)
  92.     end
  93.   end
  94.  
  95.   --monitor.drawBox(1,14,20,26)
  96.   monitor.setCursorPos(1,1)
  97.   monitor.write(capacitorInt)
  98.   monitor.setCursorPos(1,2)
  99.   monitor.write(turbineSpeed_1)
  100.   monitor.setCursorPos(1,3)
  101.   monitor.write(turbineSpeed_2)
  102.   sleep(0.2)
  103.   monitor.clear()
  104. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement