Module:Rescue Team DX Pokémon Locations table

MDFW - The Mystery Dungeon Tree of Information.
Revision as of 18:37, 23 October 2023 by Golisopod (talk | contribs)
Jump to navigation Jump to search

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

--------------------------------------------------------------------------------
--
--				Module:Rescue Team DX Pokémon Locations 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="1" class="templatePrimary" style="width: 15%;">Location</th>')
	table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 15%;">Floors</th>')
	table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 15%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Levels"}} .. '</th>')
	table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 15%;">Method</th>')
	table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 15%;">Spawn Rate</th>')
	table.insert(output, '</tr>')
	-- Data rows
	for i = 1, 100 do
		local locationArg = args["location_" .. i]
		local floorsArg = args["floors_" .. i]
		local levelsArg = args["levels_" .. i]
		local methodArg = args["method_" .. i]
		local spawnArg = args["spawnrate_" .. i]
		if not locationArg and not floorsArg and not levelsArg and not methodArg and not spawnArg then
			break -- exit loop when no more rows are found
		end
		local rowData = {}
		table.insert(rowData, '<tr class="itemsTableRow">')
		if locationArg then
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {locationArg}} .. '</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">' .. (floorsArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (levelsArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (methodArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (spawnArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		end
		table.insert(rowData, '</tr>')
		table.insert(output, table.concat(rowData))
	end