Module:Rescue Team DX Pokémon Locations table: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 30: | Line 30: | ||
break -- exit loop when no more rows are found | break -- exit loop when no more rows are found | ||
end | end | ||
local typeOne = frame:preprocess('{{#invoke:Rescue Team DX Pokémon Data Cell|rescueTeamDXPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=type1}}') | |||
local typeTwo = frame:preprocess('{{#invoke:Rescue Team DX Pokémon Data Cell|rescueTeamDXPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=type2}}') | |||
local rowData = {} | local rowData = {} | ||
table.insert(rowData, '<tr class=" | table.insert(rowData, '<tr class="monstersTableRow">') | ||
if | table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "50x50px"}} .. '</th>') | ||
table.insert(rowData, '<td class=" | table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}} .. '</td>') | ||
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team DX Pokémon Data Cell|rescueTeamDXPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=ja}}') .. '</td>') | |||
if typeTwo == nil or typeTwo == '' then | |||
table.insert(rowData, '<td class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "TypePKMN", args = {typeOne}} .. '</td>') | |||
else | else | ||
table.insert(rowData, '<td class=" | table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "TypePKMN", args = {typeOne}} .. '</td>') | ||
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "TypePKMN", args = {typeTwo}} .. '</td>') | |||
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = " | |||
end | end | ||
table.insert(rowData, '<td class="templateSecondary">' .. (levelArg or "") .. '</td>') | |||
table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or "") .. '</td>') | |||
table.insert(rowData, '</tr>') | table.insert(rowData, '</tr>') | ||
table.insert(output, table.concat(rowData)) | table.insert(output, table.concat(rowData)) | ||
end | end | ||
table.insert(output, '</table>') | |||
return table.concat(output) | |||
end | |||
return p |
Revision as of 19:06, 23 October 2023
Documentation for this module may be created at Module:Rescue Team DX Pokémon Locations table/doc
--------------------------------------------------------------------------------
--
-- Module:Rescue Team DX Pokémon Locations table
--
--------------------------------------------------------------------------------
local p = {}
local mw = require('mw')
function p.main(frame)
local args = frame.args
local output = {}
-- Header row
table.insert(output, '<table class="templateTheme" style="text-align: center; width: 50%; margin: auto;">')
table.insert(output, '<tr>')
table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 15%;">Location</th>')
table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 15%;">Floors</th>')
table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 15%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Levels"}} .. '</th>')
table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 15%;">Method</th>')
table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 15%;">Spawn Rate</th>')
table.insert(output, '</tr>')
-- Data rows
for i = 1, 100 do
local locationArg = args["location_" .. i]
local floorsArg = args["floors_" .. i]
local levelsArg = args["levels_" .. i]
local methodArg = args["method_" .. i]
local spawnArg = args["spawnrate_" .. i]
if not locationArg and not floorsArg and not levelsArg and not methodArg and not spawnArg then
break -- exit loop when no more rows are found
end
local typeOne = frame:preprocess('{{#invoke:Rescue Team DX Pokémon Data Cell|rescueTeamDXPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=type1}}')
local typeTwo = frame:preprocess('{{#invoke:Rescue Team DX Pokémon Data Cell|rescueTeamDXPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=type2}}')
local rowData = {}
table.insert(rowData, '<tr class="monstersTableRow">')
table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "50x50px"}} .. '</th>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team DX Pokémon Data Cell|rescueTeamDXPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=ja}}') .. '</td>')
if typeTwo == nil or typeTwo == '' then
table.insert(rowData, '<td class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "TypePKMN", args = {typeOne}} .. '</td>')
else
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "TypePKMN", args = {typeOne}} .. '</td>')
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "TypePKMN", args = {typeTwo}} .. '</td>')
end
table.insert(rowData, '<td class="templateSecondary">' .. (levelArg or "") .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or "") .. '</td>')
table.insert(rowData, '</tr>')
table.insert(output, table.concat(rowData))
end
table.insert(output, '</table>')
return table.concat(output)
end
return p