Advertisement
jamawie

Extreme Reactor + Turbine | Reaktor

Jun 3rd, 2020
1,047
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. local args = { ... }
  2. local this, reactor, settings, status
  3.  
  4. local minHotFluidAmount, maxHotFluidAmount
  5.  
  6. local function setup()
  7.   if #args ~= 1 then
  8.     error("reactor name not specified", 1)
  9.   end
  10.  
  11.   this = args[1]
  12.   reactor = peripheral.wrap(args[1])
  13.  
  14.   if reactor == nil then
  15.     error("'" .. args[1] .. "' could not be found")
  16.   end
  17.  
  18.   if _G.joja == nil or _G.joja.settings == nil or _G.joja.settings.reactor == nil or _G.joja.status == nil then
  19.     error("Please start the main program first!")
  20.   end
  21.  
  22.   settings = _G.joja.settings.reactor
  23.   status = _G.joja["status"]
  24.  
  25.   minHotFluidAmount = (reactor.getHotFluidAmountMax()/100)*settings["minSteamPercent"]
  26.   maxHotFluidAmount = (reactor.getHotFluidAmountMax()/100)*settings["maxSteamPercent"]
  27. end
  28.  
  29. local function control()
  30.   if not reactor.getActive() then
  31.     reactor.setActive(true)
  32.   end
  33.  
  34.   if reactor.getHotFluidAmount() < minHotFluidAmount and reactor.getCasingTemperature() < settings["maxCasingHeat"] then
  35.     reactor.setAllControlRodLevels(settings["controlRodLevel"])
  36.     status[this] = "on"
  37.   elseif reactor.getHotFluidAmount() > maxHotFluidAmount or reactor.getCasingTemperature() > settings["maxCasingHeat"] then
  38.     reactor.setAllControlRodLevels(100)
  39.     status[this] = "off"
  40.   end
  41. end
  42.  
  43. setup()
  44. while true do
  45.   control()
  46.   sleep(.25)
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement