Skip to content

Commit 3a86305

Browse files
authoredMar 6, 2020
Dungeon loot: Warn on unknown registered loot items (#2613)
1 parent 91ac075 commit 3a86305

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed
 

‎mods/dungeon_loot/mapgen.lua

+13-13
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,20 @@ local function populate_chest(pos, rand, dungeontype)
8989
amount = rand:next(loot.count[1], loot.count[2])
9090
end
9191

92-
if itemdef then
93-
if itemdef.tool_capabilities then
94-
for n = 1, amount do
95-
local wear = rand:next(0.20 * 65535, 0.75 * 65535) -- 20% to 75% wear
96-
table.insert(items, ItemStack({name = loot.name, wear = wear}))
97-
end
98-
elseif itemdef.stack_max == 1 then
99-
-- not stackable, add separately
100-
for n = 1, amount do
101-
table.insert(items, loot.name)
102-
end
103-
else
104-
table.insert(items, ItemStack({name = loot.name, count = amount}))
92+
if not itemdef then
93+
minetest.log("warning", "Registered loot item " .. loot.name .. " does not exist")
94+
elseif itemdef.tool_capabilities then
95+
for n = 1, amount do
96+
local wear = rand:next(0.20 * 65535, 0.75 * 65535) -- 20% to 75% wear
97+
table.insert(items, ItemStack({name = loot.name, wear = wear}))
98+
end
99+
elseif itemdef.stack_max == 1 then
100+
-- not stackable, add separately
101+
for n = 1, amount do
102+
table.insert(items, loot.name)
105103
end
104+
else
105+
table.insert(items, ItemStack({name = loot.name, count = amount}))
106106
end
107107
end
108108
end

0 commit comments

Comments
 (0)
Please sign in to comment.