aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2021-01-14 10:27:42 +0100
committerorwell96 <orwell@bleipb.de>2021-02-10 16:45:29 +0100
commitfad6f88bab0dc0d3999f2845d1144b7936c1a370 (patch)
tree6ef552137108775adee493e22e456137f32aee8f /advtrains
parent556e0782f718f05decf2a9e2b14ab20b5097c1ab (diff)
downloadadvtrains-fad6f88bab0dc0d3999f2845d1144b7936c1a370.tar.gz
advtrains-fad6f88bab0dc0d3999f2845d1144b7936c1a370.tar.bz2
advtrains-fad6f88bab0dc0d3999f2845d1144b7936c1a370.zip
Fix hud and trainlogic to work together
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/trainhud.lua2
-rw-r--r--advtrains/trainlogic.lua14
2 files changed, 15 insertions, 1 deletions
diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua
index 1969f0e..429c164 100644
--- a/advtrains/trainhud.lua
+++ b/advtrains/trainhud.lua
@@ -245,7 +245,7 @@ function advtrains.hud_train_format(train, flip)
if train.tarvelocity or train.atc_command then
ht[#ht+1] = "10,10=(advtrains_hud_atc.png^[resize\\:30x30^[multiply\\:cyan)"
end
- if train.ctrl.lzb then
+ if train.hud_lzb_effect_tmr then
ht[#ht+1] = "50,10=(advtrains_hud_lzb.png^[resize\\:30x30^[multiply\\:red)"
end
if train.is_shunt then
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index aebc288..a307256 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -500,11 +500,25 @@ function advtrains.train_step_b(id, train, dtime)
--atprint("in train_step_b: LZB calculation yields newindex=",new_index_curr_tv,"lzbtarget=",lzb_v_cap,"zero_barr=",lzb_next_zero_barrier,"")
+ -- LZB HUD: decrement timer and delete when 0
+ if train.hud_lzb_effect_tmr then
+ if train.hud_lzb_effect_tmr <=0 then
+ train.hud_lzb_effect_tmr = nil
+ else
+ train.hud_lzb_effect_tmr = train.hud_lzb_effect_tmr - 1
+ end
+ end
+
-- We now need to bring ctrl_*, sit_v_cap and lzb_v_cap together to determine the final controls.
local v_cap = sit_v_cap -- always defined, by default train.max_speed
if lzb_v_cap and lzb_v_cap < v_cap then
v_cap = lzb_v_cap
lever = VLEVER_BRAKE -- actually irrelevant, acceleration is not considered anyway unless v_tar is also set.
+ -- display LZB control override in the HUD
+ if lzb_v_cap <= v0 then
+ train.hud_lzb_effect_tmr = 1
+ -- This is to signal the HUD that LZB is active. This works as a timer to avoid HUD blinking
+ end
end
v_tar = ctrl_v_tar