From Dark and Darker Wiki
mNo edit summary |
mNo edit summary |
||
Line 14: | Line 14: | ||
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>"' | 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[ | for i, luckgrade in ipairs(droprate_data[4023]["luckgrade_order"]) do | ||
local probability = droprate_data["4023"]["luckgrade"][luckgrade] | local probability = droprate_data["4023"]["luckgrade"][luckgrade] | ||
if probability == nil then return "probability for '" .. luckgrade .. "' not found in droprate data for luckgrade dictionary." end | if probability == nil then return "probability for '" .. luckgrade .. "' not found in droprate data for luckgrade dictionary." end |
Revision as of 04:31, 5 May 2025
Script error: The function "loot_tables" does not exist.
local p = {}
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 = probability / item_count
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>'
return resulting_table
end
return p