diff options
author | orwell96 <orwell@bleipb.de> | 2018-06-19 19:49:24 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2018-06-19 19:49:24 +0200 |
commit | 08ac0f9c05c4623a2783749b1dee2dafa234cee6 (patch) | |
tree | e1ff64ecfcaf7688ef112b4b06f41e65a787dca2 /advtrains/init.lua | |
parent | eab240bdce187db0de7b2b2a20b8eabdb4bd3946 (diff) | |
download | advtrains-08ac0f9c05c4623a2783749b1dee2dafa234cee6.tar.gz advtrains-08ac0f9c05c4623a2783749b1dee2dafa234cee6.tar.bz2 advtrains-08ac0f9c05c4623a2783749b1dee2dafa234cee6.zip |
Check for inventory existence before serializing, and do not create it again if it already exists.
Diffstat (limited to 'advtrains/init.lua')
-rw-r--r-- | advtrains/init.lua | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/advtrains/init.lua b/advtrains/init.lua index 482c33d..de72ea1 100644 --- a/advtrains/init.lua +++ b/advtrains/init.lua @@ -281,7 +281,10 @@ advtrains.avt_save = function(remove_players_from_wagons) local _,proto = advtrains.get_wagon_prototype(wdata) if proto.has_inventory then local inv=minetest.get_inventory({type="detached", name="advtrains_wgn_"..id}) - wdata.ser_inv=advtrains.serialize_inventory(inv) + if inv then -- inventory is not initialized when wagon was never loaded + -- TOOD: What happens with unloading rails when they don't find the inventory? + wdata.ser_inv=advtrains.serialize_inventory(inv) + end end -- TODO apply save-keys here too end |