.
This commit is contained in:
parent
01a38ee6fc
commit
61e83d70e7
@ -533,16 +533,21 @@ local function controlReactor()
|
||||
|
||||
elseif state == STATES.CHARGING then
|
||||
-- CHARGING: High field input to charge up
|
||||
-- SAFETY: Prevent division by zero
|
||||
local maxField = reactorInfo.maxFieldStrength or 1
|
||||
if maxField <= 0 then maxField = 1 end
|
||||
local maxField = reactorInfo.maxFieldStrength or 0
|
||||
|
||||
local fieldStrength = (reactorInfo.fieldStrength or 0) / maxField
|
||||
local chargeNeeded = CONFIG.charge_field_target - fieldStrength
|
||||
if maxField > 0 then
|
||||
-- Reactor has valid maxFieldStrength - calculate based on charge needed
|
||||
local fieldStrength = (reactorInfo.fieldStrength or 0) / maxField
|
||||
local chargeNeeded = CONFIG.charge_field_target - fieldStrength
|
||||
|
||||
-- Charge faster when further from target
|
||||
inputRate = math.floor(maxField * math.max(0.1, chargeNeeded))
|
||||
inputRate = math.max(inputRate, calculateFieldInput())
|
||||
-- Charge faster when further from target
|
||||
inputRate = math.floor(maxField * math.max(0.1, chargeNeeded))
|
||||
inputRate = math.max(inputRate, calculateFieldInput())
|
||||
else
|
||||
-- Reactor is cold/initializing - use emergency input to charge field
|
||||
-- This provides enough power to establish the containment field
|
||||
inputRate = CONFIG.emergency_field_input
|
||||
end
|
||||
outputRate = 0
|
||||
|
||||
elseif state == STATES.WARMING_UP then
|
||||
@ -862,7 +867,7 @@ local function updateDisplay()
|
||||
-- Instructions
|
||||
mon.setCursorPos(1, y)
|
||||
mon.setTextColor(colors.gray)
|
||||
mon.write("Press Q to shutdown, R to restart")
|
||||
mon.write("Press Q to shutdown, C to charge")
|
||||
end
|
||||
|
||||
-- ============================================================================
|
||||
@ -877,8 +882,8 @@ local function handleInput()
|
||||
-- Request shutdown
|
||||
shutdownRequested = true
|
||||
print("Shutdown requested...")
|
||||
elseif key == keys.r then
|
||||
-- Restart reactor
|
||||
elseif key == keys.c then
|
||||
-- Charge reactor
|
||||
if state == STATES.OFFLINE or state == STATES.SHUTDOWN then
|
||||
shutdownRequested = false
|
||||
if reactor then
|
||||
@ -1068,7 +1073,7 @@ local function main()
|
||||
|
||||
print("Starting control loop...")
|
||||
print("Press Q to shutdown reactor")
|
||||
print("Press R to restart reactor")
|
||||
print("Press C to charge reactor")
|
||||
print("Press X to exit program")
|
||||
print("")
|
||||
print("!!! IMPORTANT: If this program stops unexpectedly,")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user