diff options
Diffstat (limited to 'advtrains')
-rw-r--r-- | advtrains/trainhud.lua | 18 | ||||
-rw-r--r-- | advtrains/trainlogic.lua | 11 |
2 files changed, 17 insertions, 12 deletions
diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua index d880ffc..6332c47 100644 --- a/advtrains/trainhud.lua +++ b/advtrains/trainhud.lua @@ -61,6 +61,7 @@ function advtrains.on_control_change(pc, train, flip) act=true else advtrains.invert_train(train.id) + advtrains.atc.train_reset_command(train) end end if pc.left then @@ -178,16 +179,21 @@ function advtrains.hud_train_format(train, flip) local topLine, firstLine local secondLine - if train.tarvelocity then + if train.tarvelocity or train.atc_command then local b=" " - local tvel=advtrains.abs_ceil(train.tarvelocity) - local tvel_kmh=advtrains.abs_ceil(advtrains.ms_to_kmh(train.tarvelocity)) + local tvels="" + if train.tarvelocity then + local tvel = advtrains.abs_ceil(train.tarvelocity) + tvels = "|"..string.rep("+", tvel)..string.rep("_", max-tvel) + end if train.atc_brake_target then b="-B-" end - secondLine="ATC"..b..": |"..string.rep("+", tvel)..string.rep("_", max-tvel).." > "..tvel_kmh.." km/h" - elseif train.atc_delay then - secondLine = "ATC waiting "..advtrains.abs_ceil(train.atc_delay).."s" + local ad = "" + if train.atc_delay then + ad = " "..advtrains.abs_ceil(train.atc_delay).."s " + end + secondLine="ATC"..b..": "..tvels..ad..(train.atc_command or "") else secondLine = "Manual operation" end diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index 6d903c5..15d8871 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -329,7 +329,6 @@ function advtrains.train_step_b(id, train, dtime) --interpret ATC command and apply auto-lever control when not actively controlled local trainvelocity = train.velocity - if train.ctrl.user then advtrains.atc.train_reset_command(train) else @@ -343,16 +342,16 @@ function advtrains.train_step_b(id, train, dtime) train.atc_brake_target=nil braketar = nil end - if train.tarvelocity and train.velocity==train.tarvelocity then - train.tarvelocity = nil - end + --if train.tarvelocity and train.velocity==train.tarvelocity then + -- train.tarvelocity = nil + --end if train.atc_wait_finish then - if not train.atc_brake_target and not train.tarvelocity then + if not train.atc_brake_target and (not train.tarvelocity or train.velocity==train.tarvelocity) then train.atc_wait_finish=nil end end if train.atc_command then - if train.atc_delay<=0 and not train.atc_wait_finish then + if (not train.atc_delay or train.atc_delay<=0) and not train.atc_wait_finish then advtrains.atc.execute_atc_command(id, train) else train.atc_delay=train.atc_delay-dtime |