Module:Sandbox: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
-------------------------------------------------------------------------------- | |||
-- | -- | ||
-- | -- Module:Rescue Team HM Moves table | ||
-- | -- | ||
-------------------------------------------------------------------------------- | |||
local p = {} | local p = {} | ||
Line 13: | Line 9: | ||
function p.main(frame) | 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="2" class="templatePrimary">[[File:Rescue Team - HM.png|alt=HM]]<br>' .. frame:expandTemplate{title = "RescueTeam", args = {"HM"}} .. '</th>') | |||
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 10%;">' .. frame:expandTemplate{title = "RescueTeam", args = {"Type"}} .. '</th>') | |||
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 20%;">Base ' .. frame:expandTemplate{title = "RescueTeam", args = {"PP"}} .. '</th>') | |||
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 20%;">Range</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, '</tr>') | |||
-- Data rows | |||
for i = 1, 100 do | |||
local moveArg = args[HM "move_" .. i] | |||
local levelArg = args["level_" .. i] | |||
if not moveArg and not levelArg then | |||
break -- exit loop when no more rows are found | |||
end | |||
local moveType = frame:preprocess('{{#invoke:Rescue Team Move Data Cell|rescueTeamMoveDataCell|name=' .. (moveArg or "") .. '|getVar=type}}') | |||
local rowData = {} | |||
table.insert(rowData, '<tr class="itemsTableRow">') | |||
if moveArg then | |||
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeam", args = {moveArg}} .. '</td>') | |||
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Move Data Cell|rescueTeamMoveDataCell|name=' .. moveArg .. '|getVar=ja}}') .. '</td>') | |||
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "TypePKMN", args = {moveType}} .. '</td>') | |||
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Move Data Cell|rescueTeamMoveDataCell|name=' .. moveArg .. '|getVar=pp}}') .. '</td>') | |||
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Move Data Cell|rescueTeamMoveDataCell|name=' .. moveArg .. '|getVar=range}}') .. '</td>') | |||
else | |||
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="templatePrimary">' .. 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>') | |||
end | |||
table.insert(rowData, '</tr>') | |||
table.insert(output, table.concat(rowData)) | |||
end | |||
table.insert(output, '</table>') | |||
return table.concat(output) | |||
end | end | ||
return p | return p |
Revision as of 18:38, 7 January 2024
--------------------------------------------------------------------------------
--
-- Module:Rescue Team HM Moves 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="2" class="templatePrimary">[[File:Rescue Team - HM.png|alt=HM]]<br>' .. frame:expandTemplate{title = "RescueTeam", args = {"HM"}} .. '</th>')
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 10%;">' .. frame:expandTemplate{title = "RescueTeam", args = {"Type"}} .. '</th>')
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 20%;">Base ' .. frame:expandTemplate{title = "RescueTeam", args = {"PP"}} .. '</th>')
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 20%;">Range</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, '</tr>')
-- Data rows
for i = 1, 100 do
local moveArg = args[HM "move_" .. i]
local levelArg = args["level_" .. i]
if not moveArg and not levelArg then
break -- exit loop when no more rows are found
end
local moveType = frame:preprocess('{{#invoke:Rescue Team Move Data Cell|rescueTeamMoveDataCell|name=' .. (moveArg or "") .. '|getVar=type}}')
local rowData = {}
table.insert(rowData, '<tr class="itemsTableRow">')
if moveArg then
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeam", args = {moveArg}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Move Data Cell|rescueTeamMoveDataCell|name=' .. moveArg .. '|getVar=ja}}') .. '</td>')
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "TypePKMN", args = {moveType}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Move Data Cell|rescueTeamMoveDataCell|name=' .. moveArg .. '|getVar=pp}}') .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Move Data Cell|rescueTeamMoveDataCell|name=' .. moveArg .. '|getVar=range}}') .. '</td>')
else
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="templatePrimary">' .. 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>')
end
table.insert(rowData, '</tr>')
table.insert(output, table.concat(rowData))
end
table.insert(output, '</table>')
return table.concat(output)
end
return p