From 2b21817b4fee688f72988b5707fbeb6f7c532e98 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Mon, 13 Jun 2022 14:17:24 +0200 Subject: On_Joinplayer: fix train ID check for attachment update Previously, statement was always false because train_id is no longer in the luaentity --- advtrains/trainlogic.lua | 7 +++++-- 1 file 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 -- cgit v1.2.3