From Dark and Darker Wiki
m (create_loot_table() table css) |
m (try to add row without any formatting/extra col/row spans) |
||
Line 4: | Line 4: | ||
local droprate_filename = "Data:Droprate Monsters Bosses.json" | local droprate_filename = "Data:Droprate Monsters Bosses.json" | ||
local lootdrop_filename = "Data:Lootdrop GhostKing.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 resulting_table = "" | local resulting_table = "" | ||
Line 10: | Line 13: | ||
resulting_table = resulting_table .. ' <caption>Loot Table at 0 Luck</caption>' | resulting_table = resulting_table .. ' <caption>Loot Table at 0 Luck</caption>' | ||
resulting_table = resulting_table .. ' <tr><th style="width:5%">Name</th><th class="tooltip" style="width:5%"><u>Luck Grade</u><span class="tooltiptext-left" style="left:50%; transform:translate(-50%); bottom:66%; width:100%">Luck Grades present on the graph but missing in the column below are associated with dropping nothing.</span></th><th style="width:5%">Rarity</th><th style="width:5%">Item Count</th></tr>"' | resulting_table = resulting_table .. ' <tr><th style="width:5%">Name</th><th class="tooltip" style="width:5%"><u>Luck Grade</u><span class="tooltiptext-left" style="left:50%; transform:translate(-50%); bottom:66%; width:100%">Luck Grades present on the graph but missing in the column below are associated with dropping nothing.</span></th><th style="width:5%">Rarity</th><th style="width:5%">Item Count</th></tr>"' | ||
-- Create body of table | |||
-- Item name, luck grade, rarity, item count | |||
for item_name in ipairs(lootdrop_data["item_order"]) do | |||
-- Get the item's data | |||
local item_data = lootdrop_data["item"] | |||
if item_data == nil then return "item_name '" .. item_name .. "' from item_order not found in lootdrop_data." end | |||
local luck_grade = item_data[1] --lua is index1 based | |||
local rarity = item_data[2] | |||
local count = item_data[3] | |||
resulting_table = resulting_table .. "<tr><td>" .. item_name .. "</td><td>" .. luck_grade .. "</td><td>" .. rarity .. "</td><td>" .. count .. "</td>" | |||
end | |||
resulting_table = resulting_table .. '</table><br>' | resulting_table = resulting_table .. '</table><br>' |
Revision as of 21:18, 3 May 2025
Script error: The function "create_monster_loot_tables" does not exist.
local p = {}
function p.create_loot_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 resulting_table = ""
resulting_table = resulting_table .. '<br>'
resulting_table = resulting_table .. '<table cellspacing="0" class="loottable stripedtable sortable jquery-tablesorter mw-collapsible" style="width:100%">'
resulting_table = resulting_table .. ' <caption>Loot Table at 0 Luck</caption>'
resulting_table = resulting_table .. ' <tr><th style="width:5%">Name</th><th class="tooltip" style="width:5%"><u>Luck Grade</u><span class="tooltiptext-left" style="left:50%; transform:translate(-50%); bottom:66%; width:100%">Luck Grades present on the graph but missing in the column below are associated with dropping nothing.</span></th><th style="width:5%">Rarity</th><th style="width:5%">Item Count</th></tr>"'
-- Create body of table
-- Item name, luck grade, rarity, item count
for item_name in ipairs(lootdrop_data["item_order"]) do
-- Get the item's data
local item_data = lootdrop_data["item"]
if item_data == nil then return "item_name '" .. item_name .. "' from item_order not found in lootdrop_data." end
local luck_grade = item_data[1] --lua is index1 based
local rarity = item_data[2]
local count = item_data[3]
resulting_table = resulting_table .. "<tr><td>" .. item_name .. "</td><td>" .. luck_grade .. "</td><td>" .. rarity .. "</td><td>" .. count .. "</td>"
end
resulting_table = resulting_table .. '</table><br>'
end
return p