diff --git a/de_react_auto b/de_react_auto index e355b93..e2f02fe 100644 --- a/de_react_auto +++ b/de_react_auto @@ -326,7 +326,12 @@ local function calculateFieldInput() local drainRate = reactorInfo.fieldDrainRate local currentStrength = reactorInfo.fieldStrength / reactorInfo.maxFieldStrength + + -- Use charge target during warmup/charging, operational target when running local targetStrength = CONFIG.target_field_strength + if state == STATES.CHARGING or state == STATES.WARMING_UP then + targetStrength = CONFIG.charge_field_target + end -- Base input = drain rate to maintain current level local baseInput = drainRate @@ -339,8 +344,8 @@ local function calculateFieldInput() local totalInput = baseInput + correction -- SAFETY: Never return less than the drain rate (would cause field to drop) - -- Add 10% safety margin - local minimumInput = drainRate * 1.1 + -- Add 10% safety margin, but ensure minimum of 1M RF/t during warmup when drain is 0 + local minimumInput = math.max(drainRate * 1.1, 1000000) return math.max(minimumInput, math.floor(totalInput)) end @@ -567,7 +572,13 @@ local function controlReactor() elseif state == STATES.WARMING_UP then -- WARMING UP: Maintain field, slowly ramp output - inputRate = calculateFieldInput() + local maxField = reactorInfo.maxFieldStrength or 0 + if maxField > 0 then + inputRate = calculateFieldInput() + else + -- maxFieldStrength not available yet - use emergency input + inputRate = CONFIG.emergency_field_input + end outputRate = calculateOutputRate() elseif state == STATES.RUNNING then