Module:Gates to Infinity Dungeon Items table
Jump to navigation
Jump to search
This template generates a list of items present in a dungeon for Gates to Infinity.
Usage
{{#invoke:Gates to Infinity Dungeon Items table|main | category = | item_1 = | floor_1 = | frequency_1 = ... | item_n = | floor_n = | frequency_n = }}
Example
{{#invoke:Gates to Infinity Dungeon Items table|main | category = Berry | item_1 = Oran Berry | floor_1 = 1 - 3 | frequency_1 = 25.00% | item_2 = Oran Berry | floor_2 = 4 - 6 | frequency_2 = 50.00% }}
File:Gates to Infinity - Berry.png Berry | |||
---|---|---|---|
English | Japanese | Floors | Item Frequency |
Oran Berry | Script error: The function "gatesToInfinityItemDataCell" does not exist. | 1 - 3 | 25.00% |
Oran Berry | Script error: The function "gatesToInfinityItemDataCell" does not exist. | 4 - 6 | 50.00% |
--------------------------------------------------------------------------------
--
-- Module:Gates to Infinity Dungeon Items table
--
--------------------------------------------------------------------------------
local p = {}
local mw = require('mw')
function p.main(frame)
local args = frame.args
local categoryArg = args["category"]
local output = {}
-- Header row
table.insert(output, '<table class="templateTheme" style="text-align: center; width: 100%;">')
table.insert(output, '<tr>')
if categoryArg then
table.insert(output, '<th class="templatePrimary" colspan="4" style="border-radius: 1rem 1rem 0 0; height:7.5rem;">[[File:Gates to Infinity - ' .. frame:preprocess('{{#switch:' .. categoryArg .. ' | Berries=Oran Berry | Food=Apple | Health Drinks=Max Elixir | Projectiles=Gravelerock | Seeds=Seed | TMs and HMs|TMs & HMs|TMs|HMs=TM | Wonder Orbs=Wonder Orb | #default={{{category|}}} }}') .. '.png|50x50px]]<br>' .. frame:expandTemplate{title = "GatesToInfinity", args = {(categoryArg or "")}} .. '</th>')
else
table.insert(output, '<th class="templatePrimary" colspan="4" style="border-radius: 1rem 1rem 0 0; height:7.5rem;">' .. frame:expandTemplate{title = "Research"} .. '</th>')
end
table.insert(output, '</tr>')
table.insert(output, '<tr>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">English</th>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Japanese</th>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Floors</th>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Item<br>Frequency</th>')
table.insert(output, '</tr>')
-- Data rows
for i = 1, 100 do
local itemArg = args["item_" .. i]
local floorArg = args["floor_" .. i]
local frequencyArg = args["frequency_" .. i]
if not itemArg and not floorArg and not frequencyArg then
break -- exit loop when no more rows are found
end
local rowData = {}
table.insert(rowData, '<tr class="itemsTableRow">')
if itemArg then
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "GatesToInfinity", args = {(itemArg or "")}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Gates to Infinity Item Data Cell|gatesToInfinityItemDataCell|name=' .. (itemArg or "") .. '}}') .. '</td>')
else
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
end
table.insert(rowData, '<td class="templateSecondary">' .. (floorArg or frame:expandTemplate{title = "Research"}) .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. (frequencyArg or frame:expandTemplate{title = "Research"}) .. '</td>')
table.insert(rowData, '</tr>')
table.insert(output, table.concat(rowData))
end
table.insert(output, '</table>')
return table.concat(output)
end
return p