Module:Rescue Team Pokémon Locations table: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 14: | Line 14: | ||
table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">') | table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">') | ||
table.insert(output, '<tr>') | table.insert(output, '<tr>') | ||
table.insert(output, '<th class="templatePrimary" colspan="1" style="width: | table.insert(output, '<th class="templatePrimary" colspan="1" style="width: 20%;">Location</th>') | ||
table.insert(output, '<th class="templatePrimary" colspan="1" style="width: | table.insert(output, '<th class="templatePrimary" colspan="1" style="width: 20%;">Floors</th>') | ||
table.insert(output, '<th class="templatePrimary" colspan="1">' .. frame:expandTemplate{title = "RescueTeam", args = {"Levels"}} .. '</th>') | table.insert(output, '<th class="templatePrimary" colspan="1">' .. frame:expandTemplate{title = "RescueTeam", args = {"Levels"}} .. '</th>') | ||
table.insert(output, '<th class="templatePrimary" colspan="1" style="width: | table.insert(output, '<th class="templatePrimary" colspan="1" style="width: 20%;">Spawn Rate</th>') | ||
table.insert(output, '<th class="templatePrimary" colspan="1" style="width: 20%;">Recruitable</th>') | |||
table.insert(output, '</tr>') | table.insert(output, '</tr>') | ||
-- Data rows | -- Data rows | ||
Line 25: | Line 26: | ||
local levelsArg = args["levels_" .. i] | local levelsArg = args["levels_" .. i] | ||
local spawnrateArg = args["spawnrate_" .. i] | local spawnrateArg = args["spawnrate_" .. i] | ||
if not locationArg and not floorsArg and not levelsArg and not spawnrateArg then | local recruitableArg = args["recruitable_" .. i] | ||
if not locationArg and not floorsArg and not levelsArg and not spawnrateArg and not recruitableArg then | |||
break -- exit loop when no more rows are found | break -- exit loop when no more rows are found | ||
end | end | ||
Line 32: | Line 34: | ||
if locationArg == nil or locationArg == '' then | if locationArg == nil or locationArg == '' then | ||
table.insert(rowData, '<th class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>') | table.insert(rowData, '<th class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>') | ||
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>') | |||
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>') | table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>') | ||
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>') | table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>') | ||
Line 41: | Line 44: | ||
table.insert(rowData, '<td class="templateSecondary">' .. (levelsArg or frame:expandTemplate{title = "Research"}) .. '</td>') | table.insert(rowData, '<td class="templateSecondary">' .. (levelsArg or frame:expandTemplate{title = "Research"}) .. '</td>') | ||
table.insert(rowData, '<td class="templateSecondary">' .. (spawnrateArg or frame:expandTemplate{title = "Research"}) .. '</td>') | table.insert(rowData, '<td class="templateSecondary">' .. (spawnrateArg or frame:expandTemplate{title = "Research"}) .. '</td>') | ||
if recruitableArg == nil or string.lower(recruitableArg) == "false" or string.lower(recruitableArg) == "no" then | |||
table.insert(rowData, '<td class="templateSecondary">✗={{No}}</td>') | |||
else | |||
table.insert(rowData, '<td class="templateSecondary">✓={{Yes}}</td>') | |||
end | |||
table.insert(rowData, '</tr>') | table.insert(rowData, '</tr>') | ||
table.insert(output, table.concat(rowData)) | table.insert(output, table.concat(rowData)) |
Revision as of 19:51, 23 December 2023
Documentation for this module may be created at Module:Rescue Team Pokémon Locations table/doc
--------------------------------------------------------------------------------
--
-- Module:Rescue Team 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; margin: auto; width: 50%;">')
table.insert(output, '<tr>')
table.insert(output, '<th class="templatePrimary" colspan="1" style="width: 20%;">Location</th>')
table.insert(output, '<th class="templatePrimary" colspan="1" style="width: 20%;">Floors</th>')
table.insert(output, '<th class="templatePrimary" colspan="1">' .. frame:expandTemplate{title = "RescueTeam", args = {"Levels"}} .. '</th>')
table.insert(output, '<th class="templatePrimary" colspan="1" style="width: 20%;">Spawn Rate</th>')
table.insert(output, '<th class="templatePrimary" colspan="1" style="width: 20%;">Recruitable</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 spawnrateArg = args["spawnrate_" .. i]
local recruitableArg = args["recruitable_" .. i]
if not locationArg and not floorsArg and not levelsArg and not spawnrateArg and not recruitableArg then
break -- exit loop when no more rows are found
end
local rowData = {}
table.insert(rowData, '<tr class="locationsTableRow">')
if locationArg == nil or locationArg == '' then
table.insert(rowData, '<th class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
else
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeam", args = {locationArg}} .. '</td>')
end
table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or frame:expandTemplate{title = "Research"}) .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. (levelsArg or frame:expandTemplate{title = "Research"}) .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. (spawnrateArg or frame:expandTemplate{title = "Research"}) .. '</td>')
if recruitableArg == nil or string.lower(recruitableArg) == "false" or string.lower(recruitableArg) == "no" then
table.insert(rowData, '<td class="templateSecondary">✗={{No}}</td>')
else
table.insert(rowData, '<td class="templateSecondary">✓={{Yes}}</td>')
end
table.insert(rowData, '</tr>')
table.insert(output, table.concat(rowData))
end
table.insert(output, '</table>')
return table.concat(output)
end
return p