ability to override initial_properties when using minetest.add_entity()

This commit is contained in:
tenplus1 2023-12-29 08:41:45 +00:00
parent be7b6bc5fe
commit a6a3b44c96
1 changed files with 23 additions and 2 deletions

25
api.lua
View File

@ -14,7 +14,7 @@ local use_vh1 = minetest.get_modpath("visual_harm_1ndicators")
-- Global
mobs = {
mod = "redo",
version = "20231205",
version = "20231229",
translate = S,
invis = minetest.global_exists("invisibility") and invisibility or {},
node_snow = minetest.registered_aliases["mapgen_snow"]
@ -3124,6 +3124,21 @@ function mob_class:mob_staticdata()
end
local is_property_name = {
hp_max = true,
physical = true,
collide_with_objects = true,
collisionbox = true,
selectionbox = true,
pointable = true,
visual_size = true,
textures = true,
is_visible = true,
stepheight = true,
glow = true,
show_on_minimap = true,
}
-- activate mob and reload settings
function mob_class:mob_activate(staticdata, def, dtime)
@ -3161,7 +3176,13 @@ function mob_class:mob_activate(staticdata, def, dtime)
t = type(stat)
if t ~= "function" and t ~= "nil" and t ~= "userdata" then
self[_] = stat
if is_property_name[_] then
self.object:set_properties({[_] = stat})
else
self[_] = stat
end
end
end
end