aboutsummaryrefslogtreecommitdiff
path: root/advtrains/trainlogic.lua
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains/trainlogic.lua')
-rw-r--r--advtrains/trainlogic.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index 35c3726..a0fdaa1 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -143,8 +143,11 @@ minetest.register_on_joinplayer(function(player)
local id=advtrains.player_to_train_mapping[pname]
if id then
for _,wagon in pairs(minetest.luaentities) do
- if wagon.is_wagon and wagon.initialized and wagon.train_id==id then
- wagon:reattach_all()
+ if wagon.is_wagon and wagon.initialized and wagon.id then
+ local wdata = advtrains.wagons[wagon.id]
+ if wdata and wdata.train_id == id then
+ wagon:reattach_all()
+ end
end
end
end