mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-28 05:21:05 +01:00
Make arrows (and all their derivatives) preserve collectable and entity properties across world unload/load
This commit is contained in:
parent
d77783a717
commit
c5eb3fa4eb
1 changed files with 10 additions and 1 deletions
|
@ -43,7 +43,7 @@ local arrow_entity = {
|
||||||
_fire_damage_resistant = true,
|
_fire_damage_resistant = true,
|
||||||
|
|
||||||
_save_fields = {
|
_save_fields = {
|
||||||
"last_pos", "startpos", "damage", "is_critical", "stuck", "stuckin", "stuckin_player", "time_in_air", "vl_projectile",
|
"last_pos", "startpos", "damage", "is_critical", "stuck", "stuckin", "stuckin_player", "time_in_air", "vl_projectile", "collectable"
|
||||||
},
|
},
|
||||||
|
|
||||||
_damage=1, -- Damage on impact
|
_damage=1, -- Damage on impact
|
||||||
|
@ -159,6 +159,9 @@ local arrow_entity = {
|
||||||
out[field] = self["_"..field]
|
out[field] = self["_"..field]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Preserve entity properties
|
||||||
|
out.properties = self.object:get_properties()
|
||||||
|
|
||||||
return minetest.serialize(out)
|
return minetest.serialize(out)
|
||||||
end,
|
end,
|
||||||
on_activate = function(self, staticdata, dtime_s)
|
on_activate = function(self, staticdata, dtime_s)
|
||||||
|
@ -168,6 +171,12 @@ local arrow_entity = {
|
||||||
local data = minetest.deserialize(staticdata)
|
local data = minetest.deserialize(staticdata)
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
|
||||||
|
-- Restore entity properties
|
||||||
|
if data.properties then
|
||||||
|
self.object:set_properties(data.properties)
|
||||||
|
data.properties = nil
|
||||||
|
end
|
||||||
|
|
||||||
-- Restore arrow state
|
-- Restore arrow state
|
||||||
local save_fields = self._save_fields
|
local save_fields = self._save_fields
|
||||||
for i = 1,#save_fields do
|
for i = 1,#save_fields do
|
||||||
|
|
Loading…
Reference in a new issue