- name - Name of the object
- category - Monster, Prop, Loose Loot
The Dark and Darker Wiki is made by and for the players. Do you want to contribute?
From Dark and Darker Wiki
Functions for making loot table. Data comes from Loot:Monster.json, Loot:Prop.json, Loot:Loose Loot.json, and the Loot: namespace.
Creates a table of drops
{{#invoke:Droprate|loot_tables|name=Lich|category=Monster}}
Script error: The function "loot_tables" does not exist.
local p = {}
function round(number, decimalPlaces)
return tonumber(string.format("%." .. (decimalPlaces or 0) .. "f", number))
end
function p.create_droprate_table(frame)
local droprate_filename = "Data:Droprate Monsters Bosses.json"
local lootdrop_filename = "Data:Lootdrop GhostKing.json"
local lootdrop_data = mw.loadJsonData(lootdrop_filename)
if lootdrop_data == nil then return "Lootdrop data file '" .. lootdrop_filename .. "' could not be found." end
local lootdrop_item_counts = lootdrop_data["luckgrade"]
local droprate_data = mw.loadJsonData(droprate_filename)
if droprate_data == nil then return "Droprate data file '" .. droprate_filename .. "' could not be found." end
local resulting_table = '<table cellspacing="0" class="loottable stripedtable sortable jquery-tablesorter mw-collapsible" style="width:100%"><caption>Drop Rates</caption><tr><th style="width:5%">Luck grade</th><th style="width:5%">Probability</th><th style="width:5%">Probability per Item</th><th style="width:5%">Item Count</th></tr>'
for i, luckgrade in ipairs(droprate_data[4023]["luckgrade_order"]) do
local probability = droprate_data[4023]["luckgrade"][luckgrade]
if probability == nil then return "probability for '" .. luckgrade .. "' not found in droprate data for luckgrade dictionary." end
local item_count = lootdrop_item_counts[luckgrade]
if item_count == nil then return "item_count for '" .. luckgrade .. "' not found in lootdrop data." end
local probability_per_item = round(probability / item_count,4)
resulting_table = resulting_table .. "<tr><td class='cr"..luckgrade.."'><b>" .. luckgrade .. "</b></td><td class='cr"..luckgrade.."'><b>" .. probability .. "</b></td><td class='cr"..luckgrade.."'><b>" .. probability_per_item .. "</b></td><td class='cr"..luckgrade.."'><b>" .. item_count .. "</b></td></tr>"
end
resulting_table = resulting_table .. '</table><br>'
for i = 1, 4 do
resulting_table = resulting_table .. resulting_table
end
return resulting_table
end
return p