aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2017-01-23 21:36:38 +0100
committerorwell96 <mono96.mml@gmail.com>2017-01-23 21:36:38 +0100
commit631e77b1898baeee96418e9011a1d9c0dc2d7162 (patch)
tree58b2f9f71e9298369b5ada6c2c5ba9fe963c1e51
parentfac8b518c940176f4d644638b1c801c2c113f872 (diff)
downloadadvtrains-631e77b1898baeee96418e9011a1d9c0dc2d7162.tar.gz
advtrains-631e77b1898baeee96418e9011a1d9c0dc2d7162.tar.bz2
advtrains-631e77b1898baeee96418e9011a1d9c0dc2d7162.zip
Do not recover wagons from minetest's static storage
Since missing wagons are spawned anyway by update_trainpart_properties, this only causes visible trouble when a train gets into loaded area. also avoids placing entities into unloaded terrain randomly.
-rw-r--r--advtrains/advtrains/wagons.lua25
1 files changed, 5 insertions, 20 deletions
diff --git a/advtrains/advtrains/wagons.lua b/advtrains/advtrains/wagons.lua
index 2729fd0..2e80fa6 100644
--- a/advtrains/advtrains/wagons.lua
+++ b/advtrains/advtrains/wagons.lua
@@ -56,28 +56,13 @@ end
wagon will save only uid in staticdata, no serialized table
]]
function wagon:on_activate(sd_uid, dtime_s)
- atprint("[wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] activated")
- self.object:set_armor_groups({immortal=1})
- if sd_uid and sd_uid~="" then
- --legacy
- --expect this to be a serialized table and handle
- if minetest.deserialize(sd_uid) then
- self:init_from_wagon_save(minetest.deserialize(sd_uid).unique_id)
- else
- self:init_from_wagon_save(sd_uid)
- end
+ if sd_uid~="" then
+ --destroy when loaded from static block.
+ self.object:remove()
+ return
end
+ self.object:set_armor_groups({immortal=1})
self.entity_name=self.name
-
- --duplicates?
- for ao_id,wagon in pairs(minetest.luaentities) do
- if wagon.is_wagon and wagon.initialized and wagon.unique_id==self.unique_id and wagon~=self then--i am a duplicate!
- atprint("[wagon "..((sd_uid and sd_uid~="" and sd_uid) or "no-id").."] duplicate found(ao_id:"..ao_id.."), removing")
- self.object:remove()
- minetest.after(0.5, function() advtrains.update_trainpart_properties(self.train_id) end)
- return
- end
- end
end
function wagon:get_staticdata()