Module:Etrian 1 Dungeon Items table: Difference between revisions
Jump to navigation
Jump to search
(Created page with "-------------------------------------------------------------------------------- -- -- Module:Etrian 1 Dungeon Items table -- -------------------------------------------------------------------------------- local p = {} local mw = require('mw') function p.main(frame) local args = frame.args local categoryArg = args["trap_" .. i] local output = {} -- Header row table.insert(output, '<table class="templateTheme" style="text-align: center; width: 1000%;">') table....") |
No edit summary |
||
Line 10: | Line 10: | ||
function p.main(frame) | function p.main(frame) | ||
local args = frame.args | local args = frame.args | ||
local categoryArg = args[" | local categoryArg = args["category_" .. i] | ||
local output = {} | local output = {} | ||
-- Header row | -- Header row | ||
table.insert(output, '<table class="templateTheme" style="text-align: center; width: 1000%;">') | table.insert(output, '<table class="templateTheme" style="text-align: center; width: 1000%;">') | ||
table.insert(output, '<tr>') | table.insert(output, '<tr>') | ||
table.insert(output, '<th class="templatePrimary" colspan="4" style="border-radius: 1rem 1rem 0 0; height:7.5rem;">[[File:Etrian 1 - {{#switch: | table.insert(output, '<th class="templatePrimary" colspan="4" style="border-radius: 1rem 1rem 0 0; height:7.5rem;">[[File:Etrian 1 - ' .. frame:preprocess('{{#switch:' .. categoryArg .. ' | Armbands=Armband | Weapons=Weapon | Shields=Shield | Herbs=Herb | Riceballs=Riceball | Jars=Jar | Projectiles=Arrows | Scrolls=Scroll | Staves=Staff | Traps=Trap | Miscellaneous=Jar Fragment | Ental=Ental | #default={{{category|}}} }}') .. '.png|50x50px]]<br>' .. frame:expandTemplate{title = "Etrian1", args = {(categoryArg or frame:expandTemplate{title = Research})}} .. '</th>') | ||
table.insert(output, '</tr>') | table.insert(output, '</tr>') | ||
table.insert(output, '<tr>') | table.insert(output, '<tr>') | ||
Line 25: | Line 25: | ||
-- Data rows | -- Data rows | ||
for i = 1, 100 do | for i = 1, 100 do | ||
local itemArg = args[" | local itemArg = args["item_" .. i] | ||
local floorArg = args["floor_" .. i] | local floorArg = args["floor_" .. i] | ||
local frequencyArg = args[" | local frequencyArg = args["frequency_" .. i] | ||
if not monsterArg and not floorArg then | if not monsterArg and not floorArg then | ||
break -- exit loop when no more rows are found | break -- exit loop when no more rows are found |
Revision as of 19:12, 26 March 2023
This template generates a list of items present in a dungeon for Etrian Mystery Dungeon.
Usage
{{#invoke:Etrian 1 Dungeon Items table|main | category = | item_1 = | floor_1 = | frequency_1 = ... | item_n = | floor_n = | frequency_n = }}
Example
{{#invoke:Etrian 1 Dungeon Items table|main | category = Scrolls | item_1 = Confuse Scroll | floor_1 = 1 - 3 | frequency_1 = 25.00% | item_2 = Light Scroll | floor_2 = 1 - 3 | frequency_2 = 25.00% }}
Lua error at line 12: attempt to concatenate global 'i' (a nil value).
--------------------------------------------------------------------------------
--
-- Module:Etrian 1 Dungeon Items table
--
--------------------------------------------------------------------------------
local p = {}
local mw = require('mw')
function p.main(frame)
local args = frame.args
local categoryArg = args["category_" .. i]
local output = {}
-- Header row
table.insert(output, '<table class="templateTheme" style="text-align: center; width: 1000%;">')
table.insert(output, '<tr>')
table.insert(output, '<th class="templatePrimary" colspan="4" style="border-radius: 1rem 1rem 0 0; height:7.5rem;">[[File:Etrian 1 - ' .. frame:preprocess('{{#switch:' .. categoryArg .. ' | Armbands=Armband | Weapons=Weapon | Shields=Shield | Herbs=Herb | Riceballs=Riceball | Jars=Jar | Projectiles=Arrows | Scrolls=Scroll | Staves=Staff | Traps=Trap | Miscellaneous=Jar Fragment | Ental=Ental | #default={{{category|}}} }}') .. '.png|50x50px]]<br>' .. frame:expandTemplate{title = "Etrian1", args = {(categoryArg or frame:expandTemplate{title = Research})}} .. '</th>')
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 monsterArg and not floorArg then
break -- exit loop when no more rows are found
end
local rowData = {}
table.insert(rowData, '<tr class="monstersTableRow">')
table.insert(rowData, '<td class="templateSecondary">' .. (itemArg or "") .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Etrian 1 Item Data Cell|etrian1ItemDataCell|name=' .. (itemArg or "") .. '}}') .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. (floorArg or "") .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. (frequencyArg or "") .. '</td>')
table.insert(rowData, '</tr>')
table.insert(output, table.concat(rowData))
end
table.insert(output, '</table>')
return table.concat(output)
end
return p