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

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--
-- Module:Rescue Team DX Pokémon Locations table
-- Module:Rescue Team Pokémon Locations table
--
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 12: Line 12:
local output = {}
local output = {}
-- Header row
-- Header row
table.insert(output, '<table class="templateTheme" style="text-align: center; width: 50%; margin: auto;">')
table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">')
table.insert(output, '<tr>')
table.insert(output, '<tr>')
table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 20%;">Location</th>')
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 20%;">Location</th>')
table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 20%;">Floors</th>')
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 20%;">Floors</th>')
table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 20%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Levels"}} .. '</th>')
table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 20%;">Method</th>')
table.insert(output, '<th colspan="1" class="templatePrimary" style="width: 20%;">Spawn Rate</th>')
table.insert(output, '</tr>')
table.insert(output, '</tr>')
-- Data rows
-- Data rows
Line 24: Line 21:
local locationArg = args["location_" .. i]
local locationArg = args["location_" .. i]
local floorsArg = args["floors_" .. i]
local floorsArg = args["floors_" .. i]
local levelsArg = args["levels_" .. i]
if not locationArg and not floorsArg then
local methodArg = args["method_" .. i]
local spawnrateArg = args["spawnrate_" .. i]
if not locationArg then
break -- exit loop when no more rows are found
break -- exit loop when no more rows are found
end
end
local rowData = {}
local rowData = {}
table.insert(rowData, '<tr class="itemsTableRow">')
table.insert(rowData, '<tr class="locationsTableRow">')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
if locationArg == nil or locationArg == '' then
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "Research"} .. '</th>')
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="templateSecondary">' .. 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>')
else
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {locationArg}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team DX Trap Data Cell|rescueTeamDXTrapDataCell|name=' .. trapArg .. '}}') .. '</td>')
end
end
table.insert(rowData, '<td class="templateSecondary">' .. (locationArg or frame:expandTemplate{title = "Research"}) .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or frame:expandTemplate{title = "Research"}) .. '</td>')
table.insert(rowData, '</tr>')
table.insert(output, table.concat(rowData))
table.insert(output, table.concat(rowData))
end
end
table.insert(output, '</table>')
table.insert(output, '</table>')
return table.concat(output)
return table.concat(output)
end
return p

Revision as of 03:59, 25 October 2023

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

--------------------------------------------------------------------------------
--
--				Module:Rescue Team 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; margin: auto; width: 50%;">')
	table.insert(output, '<tr>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 20%;">Location</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 20%;">Floors</th>')
	table.insert(output, '</tr>')
	-- Data rows
	for i = 1, 100 do
		local locationArg = args["location_" .. i]
		local floorsArg = args["floors_" .. i]
		if not locationArg and not floorsArg then
			break -- exit loop when no more rows are found
		end
		local rowData = {}
		table.insert(rowData, '<tr class="locationsTableRow">')
		if locationArg == nil or locationArg == '' then
			table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "Research"} .. '</th>')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
		else
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {locationArg}} .. '</td>')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team DX Trap Data Cell|rescueTeamDXTrapDataCell|name=' .. trapArg .. '}}') .. '</td>')
		end
		table.insert(rowData, '<td class="templateSecondary">' .. (locationArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		table.insert(rowData, '</tr>')
		table.insert(output, table.concat(rowData))
	end
	table.insert(output, '</table>')
	return table.concat(output)
end

return p