diff --git a/burnrate_driver.lua b/burnrate_driver.lua index 493b975..23db0ff 100644 --- a/burnrate_driver.lua +++ b/burnrate_driver.lua @@ -1,6 +1,7 @@ local max = 15 local init = 3 local rateStep = 0.10 +local smallRateStep = 0.01 local min = 1 local function getValue() @@ -28,6 +29,13 @@ local function stepUp() end end +local function slowStepDown() + local value = getValue() + if value > min then + reactor.setBurnRate(value - smallRateStep) + end +end + local function stepDown() local value = getValue() if value > min then @@ -35,7 +43,6 @@ local function stepDown() end end - local function watch() print("Setting Default Burn Rate to: " .. init) reactor.setBurnRate(init) @@ -48,4 +55,4 @@ local function report() monitor.clearLine() monitor.write("Burn Rate: " .. value) end -return { report = report, watch = watch, stepUp = stepUp, stepDown = stepDown } \ No newline at end of file +return { report = report, watch = watch, stepUp = stepUp, stepDown = stepDown, slowStepDown = slowStepDown } \ No newline at end of file diff --git a/coolant_driver.lua b/coolant_driver.lua index bbe0094..f8fc1e5 100644 --- a/coolant_driver.lua +++ b/coolant_driver.lua @@ -8,11 +8,13 @@ end local function checkCoolantLevel() local coolantLevel = getValue() if coolantLevel > maxValue then - print("Warning: Coolant above maximum! Stepping down burn rate.") + -- Do nothing if coolant is above the max value + elseif coolantLevel > minValue then + print("Coolant approaching minimum, slowly stepping down burn rate.") + burnRateDriver.slowStepDown() + elseif coolantLevel <= minValue then + print("Warning: Coolant below minimum! Stepping down burn rate.") burnRateDriver.stepDown() - elseif coolantLevel < minValue then - print("Warning: Coolant below minimum! Stepping up burn rate.") - burnRateDriver.stepUp() end return true end