summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2018-09-08 18:21:33 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2018-09-08 18:21:33 +0100
commit2106a081b91eefddb6e4b3fc1ea659f012634e1b (patch)
tree1baea38d6c777a05793b144a1adff278bf7638cf
parentf1476077bd4c57d6efd19edf2da2b39a8f965d12 (diff)
lifetimer check every 0.25 seconds
-rw-r--r--api.lua28
1 files changed, 18 insertions, 10 deletions
diff --git a/api.lua b/api.lua
index 83c4d5e..e920ed1 100644
--- a/api.lua
+++ b/api.lua
@@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
- version = "20180907",
+ version = "20180908",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {},
}
@@ -2746,15 +2746,8 @@ local mob_activate = function(self, staticdata, def, dtime)
end
--- main mob function
-local mob_step = function(self, dtime)
-
- if use_cmi then
- cmi.notify_step(self.object, dtime)
- end
-
- local pos = self.object:get_pos()
- local yaw = 0
+-- handle mob lifetimer and expiration
+local mob_expire = function(self, pos, dtime)
-- when lifetimer expires remove mob (except npc and tamed)
if self.type ~= "npc"
@@ -2790,6 +2783,18 @@ local mob_step = function(self, dtime)
return
end
end
+end
+
+
+-- main mob function
+local mob_step = function(self, dtime)
+
+ if use_cmi then
+ cmi.notify_step(self.object, dtime)
+ end
+
+ local pos = self.object:get_pos()
+ local yaw = 0
-- get node at foot level every quarter second
self.node_timer = (self.node_timer or 0) + dtime
@@ -2808,6 +2813,9 @@ local mob_step = function(self, dtime)
self.standing_in = node_ok({
x = pos.x, y = pos.y + y_level + 0.25, z = pos.z}, "air").name
-- print ("standing in " .. self.standing_in)
+
+ -- check for mob expiration (0.25 instead of dtime since were in a timer)
+ mob_expire(self, pos, 0.25)
end
-- check if falling, flying, floating