From 11fe530e18248b14c40edb6b56e9e3f47af3461c Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 10 Oct 2018 23:31:12 +0200 Subject: Properly handle speed restrictions --- advtrains/init.lua | 2 +- advtrains/trainhud.lua | 3 +++ advtrains/trainlogic.lua | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/advtrains/init.lua b/advtrains/init.lua index c1f280d..fc7e423 100644 --- a/advtrains/init.lua +++ b/advtrains/init.lua @@ -274,7 +274,7 @@ advtrains.avt_save = function(remove_players_from_wagons) "trainparts", "recently_collided_with_env", "atc_brake_target", "atc_wait_finish", "atc_command", "atc_delay", "door_open", "text_outside", "text_inside", "couple_lck_front", "couple_lck_back", "line", - "il_sections" + "il_sections", "speed_restriction", }) --then save it tmp_trains[id]=v diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua index 9ea7466..d880ffc 100644 --- a/advtrains/trainhud.lua +++ b/advtrains/trainhud.lua @@ -197,6 +197,9 @@ function advtrains.hud_train_format(train, flip) topLine=" ["..mletter[fct].."] {"..levers.."} "..doorstr[(train.door_open or 0) * fct] firstLine=attrans("Speed:").." |"..string.rep("+", vel)..string.rep("_", res-vel).."|"..string.rep("_", max-res).."> "..vel_kmh.." km/h" + if train.speed_restriction == 0 then + firstLine = "OVERRUN RED SIGNAL! Examine situation and reverse train to move again." + end return (train.debug or "").."\n"..topLine.."\n"..firstLine.."\n"..secondLine end diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index f94bda0..4ca212f 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -1029,7 +1029,7 @@ function advtrains.invert_train(train_id) advtrains.update_trainpart_properties(train_id, true) -- TODO: this should actually be SHUNT_MAX_SPEED, but signals and lzb is not present everywhere - advtrains.speed_restriction = nil + train.speed_restriction = nil end -- returns: train id, index of one of the trains that stand at this position. -- cgit v1.2.3