add check for no drops

This commit is contained in:
TenPlus1 2018-07-19 09:19:00 +01:00
parent 63c9812dad
commit 4badcec318

11
api.lua
View File

@ -3,7 +3,7 @@
mobs = {} mobs = {}
mobs.mod = "redo" mobs.mod = "redo"
mobs.version = "20180710" mobs.version = "20180719"
-- Intllib -- Intllib
@ -350,6 +350,11 @@ end
-- drop items -- drop items
local item_drop = function(self, cooked) 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 -- no drops if disabled by setting
if not mobs_drop_items then return end if not mobs_drop_items then return end
@ -359,13 +364,11 @@ local item_drop = function(self, cooked)
local obj, item, num local obj, item, num
local pos = self.object:get_pos() local pos = self.object:get_pos()
self.drops = self.drops or {} -- nil check
for n = 1, #self.drops do for n = 1, #self.drops do
if random(1, self.drops[n].chance) == 1 then 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 item = self.drops[n].name
-- cook items when true -- cook items when true