Module:Rescue Team DX Moves table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
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; width: 50%;">')
table.insert(output, '<table class="templateTheme" style="text-align: center; width: 50%;">')
table.insert(output, '<tr>')
table.insert(output, '<tr>')
table.insert(output, '<th colspan="2" class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Moves"}} .. '</th>')
table.insert(output, '<th colspan="2" class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Move"}} .. '</th>')
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 15%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Type"}} .. '</th>')
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 15%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Type"}} .. '</th>')
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 15%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Level"}} .. '</th>')
table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 15%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Level"}} .. '</th>')

Revision as of 09:02, 14 October 2023

Documentation for this module may be created at Module:Rescue Team DX Moves table/doc

--------------------------------------------------------------------------------
--
--				Module:Rescue Team DX 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%;">')
	table.insert(output, '<tr>')
	table.insert(output, '<th colspan="2" class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Move"}} .. '</th>')
	table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 15%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Type"}} .. '</th>')
	table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 15%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Level"}} .. '</th>')
	table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 15%;">Base ' .. frame:expandTemplate{title = "RescueTeamDX", args = {"PP"}} .. '</th>')
	table.insert(output, '<th rowspan="2" class="templatePrimary" style="width: 15%;">Range</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, 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 DX Move Data Cell|rescueTeamDXMoveDataCell|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 = "RescueTeamDX", args = {(moveArg or "")}} .. '</td>')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team DX Move Data Cell|rescueTeamDXMoveDataCell|name=' .. (moveArg or "") .. '|getVar=ja}}') .. '</td>')
			table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "TypePKMN", args = {moveType}} .. '</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>')
		end
		table.insert(rowData, '<td class="templateSecondary">' .. (levelArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		if moveArg then
			table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team DX Move Data Cell|rescueTeamDXMoveDataCell|name=' .. (moveArg or "") .. '|getVar=pp}}') .. '</td>')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team DX Move Data Cell|rescueTeamDXMoveDataCell|name=' .. (moveArg or "") .. '|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>')
		end
		table.insert(rowData, '</tr>')
		table.insert(output, table.concat(rowData))
	end
	table.insert(output, '</table>')
	return table.concat(output)
end

return p