Module:Rescue Team TM Moves table
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Rescue Team TM Moves table/doc
--------------------------------------------------------------------------------
--
-- Module:Rescue Team TM 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 - TM.png|alt=TM]]<br>' .. frame:expandTemplate{title = "RescueTeam", args = {"TM"}} .. '</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["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 = "RescueTeamType", 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