diff options
author | TenPlus1 <kinsellaja@yahoo.com> | 2018-07-19 09:19:00 +0100 |
---|---|---|
committer | TenPlus1 <kinsellaja@yahoo.com> | 2018-07-19 09:19:00 +0100 |
commit | 4badcec3187cb10a561bd68b126747600ac343d4 (patch) | |
tree | 1534c223dfee172d02ce07021f3f0980d702682e | |
parent | 63c9812dad43adfb5736408f48a61ff02267d9ed (diff) |
add check for no drops
-rw-r--r-- | api.lua | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -3,7 +3,7 @@ mobs = {} mobs.mod = "redo" -mobs.version = "20180710" +mobs.version = "20180719" -- Intllib @@ -350,6 +350,11 @@ end -- drop items local item_drop = function(self, cooked) + -- check for nil or no drops + if not self.drops or #self.drops == 0 then + return + end + -- no drops if disabled by setting if not mobs_drop_items then return end @@ -359,13 +364,11 @@ local item_drop = function(self, cooked) local obj, item, num local pos = self.object:get_pos() - self.drops = self.drops or {} -- nil check - for n = 1, #self.drops do if random(1, self.drops[n].chance) == 1 then - num = random(self.drops[n].min or 1, self.drops[n].max or 1) + num = random(self.drops[n].min or 0, self.drops[n].max or 1) item = self.drops[n].name -- cook items when true |