diff options
author | orwell <orwell@bleipb.de> | 2025-01-28 22:24:03 +0100 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2025-01-28 22:24:03 +0100 |
commit | a212310913c33fb855ca0f262beda6d857382ff8 (patch) | |
tree | 9e94937aa2e1d4c3b1be12accc4455e8bf22b866 /advtrains | |
parent | e3e711e04cf6036eb6f3e4c05007bb7258b01449 (diff) | |
download | advtrains-a212310913c33fb855ca0f262beda6d857382ff8.tar.gz advtrains-a212310913c33fb855ca0f262beda6d857382ff8.tar.bz2 advtrains-a212310913c33fb855ca0f262beda6d857382ff8.zip |
ATC: add "G" command to wait for green signal, improve ATC hud, potentially fix LZB issue
Diffstat (limited to 'advtrains')
-rw-r--r-- | advtrains/atc.lua | 8 | ||||
-rw-r--r-- | advtrains/lzb.lua | 3 | ||||
-rw-r--r-- | advtrains/trainhud.lua | 15 | ||||
-rw-r--r-- | advtrains/trainlogic.lua | 12 |
4 files changed, 34 insertions, 4 deletions
diff --git a/advtrains/atc.lua b/advtrains/atc.lua index b572cdc..8e54b08 100644 --- a/advtrains/atc.lua +++ b/advtrains/atc.lua @@ -94,6 +94,7 @@ function atc.train_reset_command(train, keep_tarvel) train.atc_brake_target=nil train.atc_wait_finish=nil train.atc_wait_autocouple=nil + train.atc_wait_signal=nil train.atc_arrow=nil if not keep_tarvel then train.tarvelocity=nil @@ -278,6 +279,10 @@ local matchptn={ train.atc_wait_autocouple=true return 3 end, + ["G"]=function(id, train) + train.atc_wait_signal=true + return 1 + end, } eval_conditional = function(command, arrow, speed) @@ -375,7 +380,8 @@ function atc.execute_atc_command(id, train) train.atc_command=string.sub(command, patlen+1) if train.atc_delay<=0 and not train.atc_wait_finish - and not train.atc_wait_autocouple then + and not train.atc_wait_autocouple + and not train.atc_wait_signal then --continue (recursive, cmds shouldn't get too long, and it's a end-recursion.) atc.execute_atc_command(id, train) end diff --git a/advtrains/lzb.lua b/advtrains/lzb.lua index 2853218..116777c 100644 --- a/advtrains/lzb.lua +++ b/advtrains/lzb.lua @@ -265,7 +265,8 @@ end advtrains.te_register_on_new_path(function(id, train) advtrains.lzb_invalidate(train) -- Taken care of in pre-move hook (see train_step_b) - --look_ahead(id, train) + -- 2025-01-28 - do anyway, there seems to be an issue + look_ahead(id, train) end) advtrains.te_register_on_invalidate_ahead(function(id, train, start_idx) diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua index c133a54..b1e2036 100644 --- a/advtrains/trainhud.lua +++ b/advtrains/trainhud.lua @@ -277,7 +277,20 @@ function advtrains.hud_train_format(train, flip) end if train.atc_command then - table.insert(st, ("ATC: %s%s"):format(train.atc_delay and advtrains.abs_ceil(train.atc_delay).."s " or "", train.atc_command or "")) + local delay_str = "" + if train.atc_delay and train.atc_delay >= 0 then + delay_str = advtrains.abs_ceil(train.atc_delay).."s " + end + if train.atc_wait_finish then + delay_str = delay_str.."[W] " + end + if train.atc_wait_autocouple then + delay_str = delay_str.."[Cpl] " + end + if train.atc_wait_signal then + delay_str = delay_str.."[G] " + end + table.insert(st, ("ATC: %s%s"):format(delay_str, train.atc_command or "")) end return table.concat(st,"\n"), tostring(hud) diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index 0e588c7..c49d7e3 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -427,7 +427,8 @@ function advtrains.train_step_b(id, train, dtime) if train.atc_command then if (not train.atc_delay or train.atc_delay<=0) and not train.atc_wait_finish - and not train.atc_wait_autocouple then + and not train.atc_wait_autocouple + and not train.atc_wait_signal then advtrains.atc.execute_atc_command(id, train) elseif train.atc_delay and train.atc_delay > 0 then train.atc_delay=train.atc_delay-dtime @@ -456,6 +457,15 @@ function advtrains.train_step_b(id, train, dtime) train.atc_wait_finish=nil end end + -- clear atc_wait_signal immediately when the next LZB checkpoint is not a "stop" + -- (but make sure lzb is initialized, otherwise wait for it) + if train.atc_wait_signal and train.lzb then + local first_ckp = train.lzb.checkpoints and train.lzb.checkpoints[1] + -- no checkpoint exists, or it has a speed of either nil or >0 + if not first_ckp or first_ckp.speed ~= 0 then + train.atc_wait_signal = nil + end + end if train.tarvelocity and train.tarvelocity>v0 then --atprint("in train_step_b: applying ATC ACCEL", train.tarvelocity) |