fix(udsendelse): fælles udsendelsesport for Start alle, markarbejde, marksiloer og flow-genstart; én indstilling under Indstillinger (v1.62.237)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
-- AD Launch Gate
|
||||
-- Fælles port for alt der sender en maskine ud fra parkeringen: "Start alle"-køen, markarbejde, marksiloer og
|
||||
-- genstart af ledige flow-traktorer. Højst én udsendelse pr. intervalMs() på tværs af dem alle — før havde hver sin
|
||||
-- egen afstand, så to traktorer kørte ud i samme sekund (in-game 16/10: Vario 7 fra køen + Tømmevogn 8 til F22).
|
||||
-- Intervallet er indstillingen startAllStaggerSec ("Tid mellem hver maskine der sendes ud"). Ren logik; eget ur via tick.
|
||||
|
||||
ADLaunchGate = {}
|
||||
ADLaunchGate.DEFAULT_MS = 10000
|
||||
|
||||
local clockMs, lastLaunchMs = 0, nil
|
||||
|
||||
function ADLaunchGate.reset()
|
||||
clockMs, lastLaunchMs = 0, nil
|
||||
end
|
||||
|
||||
function ADLaunchGate.tick(dt)
|
||||
clockMs = clockMs + (dt or 0)
|
||||
end
|
||||
|
||||
function ADLaunchGate.intervalMs()
|
||||
local seconds = ADSettings ~= nil and tonumber(ADSettings.get("startAllStaggerSec")) or nil
|
||||
if seconds == nil then return ADLaunchGate.DEFAULT_MS end
|
||||
return seconds * 1000
|
||||
end
|
||||
|
||||
-- Må der sendes en maskine ud nu?
|
||||
function ADLaunchGate.isOpen()
|
||||
return lastLaunchMs == nil or clockMs - lastLaunchMs >= ADLaunchGate.intervalMs()
|
||||
end
|
||||
|
||||
-- Kaldes når en maskine faktisk er sendt ud.
|
||||
function ADLaunchGate.markLaunched()
|
||||
lastLaunchMs = clockMs
|
||||
end
|
||||
Reference in New Issue
Block a user