]> git.lizzy.rs Git - Crafter.git/blobdiff - mods/mob/api/timers.lua
fix mobs not getting hurt inside hurt_inside group nodes
[Crafter.git] / mods / mob / api / timers.lua
index 053e2a345958239f4b3fd963e442145e626c343e..82ad6c892bf4b2ad485081edc1152ebc825b94da 100644 (file)
@@ -59,6 +59,16 @@ mobs.create_timer_functions = function(def,mob_register)
                end
        end
 
+       if def.custom_timer then
+               mob_register.do_custom_timer = function(self,dtime)
+                       self.c_timer = self.c_timer + dtime
+                       if self.c_timer >= self.custom_timer then
+                               self.c_timer = 0 
+                               self.custom_timer_function(self,dtime)
+                       end
+               end
+       end
+
        mob_register.manage_projectile_timer = function(self,dtime)
                self.projectile_timer = self.projectile_timer - dtime
        end
@@ -69,7 +79,8 @@ mobs.create_timer_functions = function(def,mob_register)
                        if self.friendly_in_daylight_timer >= 2 then
                                self.friendly_in_daylight_timer = 0
                                local pos = self.object:get_pos()
-                               if minetest.get_node_light(pos) >= 13 then --1 greater than torch light
+                               local light = minetest.get_node_light(pos)
+                               if pos and light and light >= 13 then --1 greater than torch light
                                        if self.following == false then
                                                self.hostile = false
                                        end