aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--advtrains/atc.lua3
-rw-r--r--advtrains/path.lua2
-rw-r--r--advtrains/trainlogic.lua3
3 files changed, 7 insertions, 1 deletions
diff --git a/advtrains/atc.lua b/advtrains/atc.lua
index 465a0ec..00cfde1 100644
--- a/advtrains/atc.lua
+++ b/advtrains/atc.lua
@@ -32,6 +32,9 @@ function atc.send_command(pos, par_tid)
atc.train_reset_command(train_id)
local arrowconn=atc.controllers[pts].arrowconn
local train=advtrains.trains[train_id]
+ if train.path == nil then
+ return
+ end
for index, ppos in pairs(train.path) do
if vector.equals(advtrains.round_vector_floor_y(ppos), pos) then
advtrains.trains[train_id].atc_arrow =
diff --git a/advtrains/path.lua b/advtrains/path.lua
index 506f27f..4955854 100644
--- a/advtrains/path.lua
+++ b/advtrains/path.lua
@@ -18,7 +18,7 @@ function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return
local nconnid = advtrains.get_matching_conn(pconnid, #midconns)
local next, next_connid, _, nextrailheight = advtrains.get_adjacent_rail(mid, midconns, nconnid, drives_on)
- if not next then
+ if not next or not midconns or not midconns[nconnid] then
return nil
end
return vector.add(advtrains.round_vector_floor_y(next), {x=0, y=nextrailheight, z=0}), midconns[nconnid].c
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index c3fbe4a..6ab2b0d 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -540,6 +540,9 @@ function advtrains.train_step_b(id, train, dtime)
local collpos
local coll_grace=1
+ if train.end_index == nil then
+ return
+ end
if train.movedir==1 then
collpos=advtrains.get_real_index_position(train.path, train.index-coll_grace)
else