On_Joinplayer: fix train ID check for attachment update

Previously, statement was always false because train_id is no longer in the luaentity
master
orwell96 2022-06-13 14:17:24 +02:00
parent 744aee2cdd
commit 2b21817b4f
1 changed files with 5 additions and 2 deletions

View File

@ -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