Module:Rescue Team DX Camp Pokémon table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
mNo edit summary
Tag: Manual revert
mNo edit summary
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--
-- Module:Rescue Team DX Camp Pokémon table
-- Module:Rescue Team DX Camp Pokémon table
--
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 9: Line 9:


function p.main(frame)
function p.main(frame)
local data = require("Module:Rescue Team DX Pokémon Data Cell")
local metatable = {__index = function () return "" end}
setmetatable(data, metatable)
local args = frame.args
local args = frame.args
local output = {}
 
local output = mw.html.create()
local header = mw.html.create()
-- Header row
-- Header row
table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">')
header
table.insert(output, '<tr>')
:tag('tr')
table.insert(output, '<th class="templatePrimary" colspan="2" rowspan="1" style="width: 33.4%;">Sprite</th>')
:tag('th'):attr("colspan", "2"):wikitext("Sprite"):done()
table.insert(output, '<th class="templatePrimary" colspan="2" style="width: 33.3%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Pokémon"}} .. '</th>')
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Pokémon"}}):done()
table.insert(output, '<th class="templatePrimary" colspan="2" rowspan="2" style="width: 33.3%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Types"}} .. '</th>')
:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Type"}}):done()
table.insert(output, '</tr>')
:tag('tr')
table.insert(output, '<tr>')
:tag('th'):cssText("width: 20%"):wikitext("Normal"):done()
table.insert(output, '<th class="templatePrimary" style="width: 16.7%;">Normal</th>')
:tag('th'):cssText("width: 20%"):wikitext("Shiny"):done()
table.insert(output, '<th class="templatePrimary" style="width: 16.7%;">Shiny</th>')
:tag('th'):cssText("width: 20%"):wikitext("English"):done()
table.insert(output, '<th class="templatePrimary" style="width: 16.65%;">English</th>')
:tag('th'):cssText("width: 20%"):wikitext("Japanese"):done()
table.insert(output, '<th class="templatePrimary" style="width: 16.65%;">Japanese</th>')
 
table.insert(output, '</tr>')
-- Data rows
-- Data rows
for i = 1, 150 do
local rows = mw.html.create()
local i = 1
 
while true do
local row = mw.html.create()
local monsterArg = args["pokémon_" .. i]
local monsterArg = args["pokémon_" .. i]
local shinyArg = args["shiny_" .. i]
local shinyArg = args["shiny_" .. i]
if not monsterArg then
 
if not monsterArg and not shinyArg then
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 typeOne = data[monsterArg]["type1"] or ""
local rowData = {}
local typeTwo = data[monsterArg]["type2"] or ""
table.insert(rowData, '<tr class="monstersTableRow">')
 
table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "100x100px"}} .. '</th>')
row
if shinyArg == nil or shinyArg == '' then
:tag('tr'):done()
table.insert(rowData, '<td class="templatePrimary">Unavailable</td>')
if shinyArg == nil or shinyArg == '' or string.lower(shinyArg) == 'no' or string.lower(shinyArg) == 'false' then
row
:tag('th'):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "64x64px"}}):done()
:tag('th'):wikitext("None"):done()
else
else
table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXSprite", args = {(shinyArg or ""), shiny="true", size = "100x100px"}} .. '</th>')
row
:tag('th'):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "64x64px"}}):done()
:tag('th'):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "64x64px", shiny = "true"}}):done()
end
end
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}} .. '</td>')
row
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team DX Pokémon Data Cell|rescueTeamDXPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=ja}}') .. '</td>')
:tag('td'):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}}):done()
:tag('td'):wikitext(data[monsterArg]["ja"]):done()
 
if typeTwo == nil or typeTwo == '' then
if typeTwo == nil or typeTwo == '' then
table.insert(rowData, '<td class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "TypePKMN", args = {typeOne}} .. '</td>')
row
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}}):done()
else
else
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "TypePKMN", args = {typeOne}} .. '</td>')
row
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "TypePKMN", args = {typeTwo}} .. '</td>')
:tag('th'):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}}):done()
:tag('th'):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeTwo}}):done()
end
end
table.insert(rowData, '</tr>')
 
table.insert(output, table.concat(rowData))
rows
:node(row)
:allDone()
i = i + 1
end
end
table.insert(output, '</table>')
 
return table.concat(output)
output
:tag('table'):addClass("wikitable"):cssText("text-align: center; margin: auto; width: 50%;")
:node(header)
:node(rows)
return tostring(output)
 
end
end


return p
return p

Latest revision as of 09:34, 26 January 2025

Template-info.png Documentation

This template generates a list of Pokémon present in a Rescue Team Camp for Pokémon Mystery Dungeon: Rescue Team DX.

Usage

{{#invoke:Rescue Team DX Camp Pokémon table|main
  | pokémon_1 = 
  | shiny_1  = 
  ...
  | pokémon_n = 
  | shiny_n  = 
}}

Example

{{#invoke:Rescue Team DX Camp Pokémon table|main
  | pokémon_1 = Celebi
  | shiny_1   = yes
  |-
  | pokémon_2 = Pikachu
  | shiny_2   = no
}}
SpritePokémonType
NormalShinyEnglishJapanese
Celebi's sprite.Celebi's shiny sprite.CelebiセレビィPsychic-typeGrass-type
Pikachu's sprite.NonePikachuピカチュウElectric-type

--------------------------------------------------------------------------------
--
--					Module:Rescue Team DX Camp Pokémon table
--
--------------------------------------------------------------------------------

local p = {}
local mw = require('mw')

function p.main(frame)
	local data = require("Module:Rescue Team DX Pokémon Data Cell")
	local metatable = {__index = function () return "" end}
	setmetatable(data, metatable)
	local args = frame.args

	local output = mw.html.create()
	local header = mw.html.create()
	-- Header row
	header
		:tag('tr')
			:tag('th'):attr("colspan", "2"):wikitext("Sprite"):done()
			:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Pokémon"}}):done()
			:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Type"}}):done()
		:tag('tr')
			:tag('th'):cssText("width: 20%"):wikitext("Normal"):done()
			:tag('th'):cssText("width: 20%"):wikitext("Shiny"):done()
			:tag('th'):cssText("width: 20%"):wikitext("English"):done()
			:tag('th'):cssText("width: 20%"):wikitext("Japanese"):done()

	-- Data rows
	local rows = mw.html.create()
	local i = 1

	while true do
		local row = mw.html.create()
		local monsterArg = args["pokémon_" .. i]
		local shinyArg = args["shiny_" .. i]

		if not monsterArg and not shinyArg then
			break -- exit loop when no more rows are found
		end

		local typeOne = data[monsterArg]["type1"] or ""
		local typeTwo = data[monsterArg]["type2"] or ""

		row
			:tag('tr'):done()
			
		if shinyArg == nil or shinyArg == '' or string.lower(shinyArg) == 'no' or string.lower(shinyArg) == 'false' then
			row
				:tag('th'):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "64x64px"}}):done()
				:tag('th'):wikitext("None"):done()
		else
			row
				:tag('th'):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "64x64px"}}):done()
				:tag('th'):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "64x64px", shiny = "true"}}):done()
		end
		row
			:tag('td'):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}}):done()
			:tag('td'):wikitext(data[monsterArg]["ja"]):done()

		if typeTwo == nil or typeTwo == '' then
			row
				:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}}):done()
		else
			row
				:tag('th'):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}}):done()
				:tag('th'):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeTwo}}):done()
		end

		rows
			:node(row)
			:allDone()
		
		i = i + 1
	end

	output
		:tag('table'):addClass("wikitable"):cssText("text-align: center; margin: auto; width: 50%;")
			:node(header)
			:node(rows)
	return tostring(output)

end

return p