From 1a0c9cf52a5945c223ceda3277add3b0a63fe558 Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Tue, 8 Nov 2022 10:22:34 -0500 Subject: [PATCH] fixed a crash --- cybersyn/scripts/main.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 01602d6..eacbf12 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -695,13 +695,15 @@ local function on_train_built(event) end local function on_train_changed(event) local train_e = event.train - local train = global.trains[train_e.id] if train_e.valid then + local train = global.trains[train_e.id] if train_e.state == defines.train_state.wait_station then local stop = train_e.station if stop and stop.valid and stop.name == "train-stop" then if global.stations[stop.unit_number] then - on_train_arrives_buffer(global, stop, train) + if train then + on_train_arrives_buffer(global, stop, train) + end else local depot = global.depots[stop.unit_number] if depot then