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