summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 5f681d8..1242186 100644
--- a/init.lua
+++ b/init.lua
@@ -530,14 +530,23 @@ doc.new_category("nodes", {
for j=1,#data.def.drop.items[i].items do
local subrarity = rarity * (#data.def.drop.items[i].items)
local dropstack = ItemStack(data.def.drop.items[i].items[j])
+ local itemstring = dropstack:get_name()
local desc = get_desc(dropstack)
local count = dropstack:get_count()
- table.insert(probtable, {desc = desc, count = count, rarity = subrarity})
+ table.insert(probtable, {itemstring = itemstring, desc = desc, count = count, rarity = subrarity})
end
if max ~= nil then
remaining_rarity = 1/(1/remaining_rarity - 1/rarity)
end
end
+ -- Do some cleanup of the probability table
+ if max == 1 then
+ -- Sort by rarity
+ local comp = function(p1, p2)
+ return p1.rarity < p2.rarity
+ end
+ table.sort(probtable, comp)
+ end
-- Output probability table
local icount = 0
for i=1, #probtable do