summaryrefslogtreecommitdiff
path: root/api.lua
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2017-09-01 12:27:31 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2017-09-01 12:27:31 +0100
commitd28c4100950df54fe0d57d573e1f3ba0b5d4a0d1 (patch)
tree9621c8cace8ebc3cf10fb1114083963e34e59604 /api.lua
parentf19960e5db01b9cac0e897010a7937f8793d27ee (diff)
added on_spawn function to mobs registry
Diffstat (limited to 'api.lua')
-rw-r--r--api.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/api.lua b/api.lua
index 6e50900..36fa6a1 100644
--- a/api.lua
+++ b/api.lua
@@ -2449,6 +2449,13 @@ local mob_activate = function(self, staticdata, def, dtime)
update_tag(self)
set_animation(self, "stand")
+ -- run on_spawn function if found
+ if self.on_spawn and not self.on_spawn_run then
+ if self.on_spawn(self) then
+ self.on_spawn_run = true -- if true, set flag to run once only
+ end
+ end
+
if use_cmi then
self._cmi_components = cmi.activate_components(self.serialized_cmi_components)
cmi.notify_activate(self.object, dtime)
@@ -2687,6 +2694,8 @@ minetest.register_entity(name, {
facing_fence = false,
_cmi_is_mob = true,
+ on_spawn = def.on_spawn,
+
on_blast = def.on_blast or do_tnt,
on_step = mob_step,