From a80b8dc3b0b285d54a71dc15bf80bbf75e421857 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Sat, 16 Apr 2016 09:58:53 +0100 Subject: [PATCH] added punch_capabilities error check --- api.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api.lua b/api.lua index 1942163..b02177b 100644 --- a/api.lua +++ b/api.lua @@ -1,5 +1,5 @@ --- Mobs Api (15th April 2016) +-- Mobs Api (16th April 2016) mobs = {} mobs.mod = "redo" @@ -416,7 +416,7 @@ do_env_damage = function(self) check_for_death(self) end --- jump if facing a solid node (not fences) +-- jump if facing a solid node (not fences or gates) do_jump = function(self) if self.fly @@ -549,6 +549,7 @@ function follow_holding(self, clicker) return false end +-- find two animals of same type and breed if nearby and horny local function breed(self) -- child take 240 seconds before growing into adult @@ -682,6 +683,7 @@ local function breed(self) end end +-- find and replace what mob is looking for (grass, wheat etc.) function replace(self, pos) if self.replace_rate @@ -1702,7 +1704,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) tflp = 0.2 end - for group,_ in pairs(tool_capabilities.damage_groups) do + for group,_ in pairs( (tool_capabilities.damage_groups or {}) ) do tmp = tflp / (tool_capabilities.full_punch_interval or 1.4)