Module:Rescue Team Friend Area Pokémon table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
m (Golisopod moved page Module:Rescue Team Camp Pokémon table to Module:Rescue Team Friend Area Pokémon table without leaving a redirect)
mNo edit summary
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--
-- Module:Rescue Team Camp Pokémon table
-- Module:Rescue Team Friend Area Pokémon table
--
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

Revision as of 19:50, 15 January 2024

Documentation for this module may be created at Module:Rescue Team Friend Area Pokémon table/doc

--------------------------------------------------------------------------------
--
--				Module:Rescue Team Friend Area Pokémon 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" rowspan="2" style="width: 20%;">Sprite</th>')
	table.insert(output, '<th class="templatePrimary" colspan="2" style="width: 20%;">' .. frame:expandTemplate{title = "RescueTeam", args = {"Pokémon"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" colspan="2" rowspan="2" style="width: 20%;">' .. frame:expandTemplate{title = "RescueTeam", args = {"Types"}} .. '</th>')
	table.insert(output, '</tr>')
	table.insert(output, '<tr>')
	table.insert(output, '<th class="templatePrimary" style="width: 20%;">English</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 20%;">Japanese</th>')
	table.insert(output, '</tr>')
	-- Data rows
	for i = 1, 150 do
		local monsterArg = args["pokémon_" .. i]
		if not monsterArg then
			break -- exit loop when no more rows are found
		end
		local typeOne = frame:preprocess('{{#invoke:Rescue Team Pokémon Data Cell|rescueTeamPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=type1}}')
		local typeTwo = frame:preprocess('{{#invoke:Rescue Team Pokémon Data Cell|rescueTeamPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=type2}}')
		local rowData = {}
		table.insert(rowData, '<tr class="monstersTableRow">')
		table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamSprite", args = {(monsterArg or "")}} .. '</th>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeam", args = {(monsterArg or "")}} .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Pokémon Data Cell|rescueTeamPokemonDataCell|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, '</tr>')
		table.insert(output, table.concat(rowData))
	end
	table.insert(output, '</table>')
	return table.concat(output)
end

return p