summaryrefslogtreecommitdiff
path: root/il_timetable
diff options
context:
space:
mode:
Diffstat (limited to 'il_timetable')
-rw-r--r--il_timetable/init_code.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/il_timetable/init_code.lua b/il_timetable/init_code.lua
index 9c86dec..191dfc0 100644
--- a/il_timetable/init_code.lua
+++ b/il_timetable/init_code.lua
@@ -260,11 +260,13 @@ function F.ttp_begin(p)
end
if event.schedule then
-- departure. save actual departure time in tt
- S.ttt[atc_id].actual_dep = rwt.now()
- local delay = rwt.diff(S.ttt[atc_id].desired_dep, S.ttt[atc_id].actual_dep)
- atc_set_text_inside(F.ttp[p.tt].inside_line_desc
- .."\nDelay:"..rwt.to_string(delay, true))
- S.ttt[atc_id].last_delay = delay
+ if S.ttt[atc_id] then -- failsafe: if entry is deleted externally somehow, train just departs and is not tracked by tt (makes resetting S.ttt possible)
+ S.ttt[atc_id].actual_dep = rwt.now()
+ local delay = rwt.diff(S.ttt[atc_id].desired_dep, S.ttt[atc_id].actual_dep)
+ atc_set_text_inside(F.ttp[p.tt].inside_line_desc
+ .."\nDelay:"..rwt.to_string(delay, true))
+ S.ttt[atc_id].last_delay = delay
+ end
if p.reverse then
atc_send(RDEPCMD)
else