Module:Rescue Team Item Locations table

MDFW - The Mystery Dungeon Tree of Information.
Revision as of 23:56, 23 January 2024 by Golisopod (talk | contribs) (Created page with "-------------------------------------------------------------------------------- -- -- Module:Rescue Team Item 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>')...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Rescue Team Item Locations table/doc

--------------------------------------------------------------------------------
--
--				Module:Rescue Team Item 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" colspan="1" style="width: 25%;">Location</th>')
	table.insert(output, '<th class="templatePrimary" colspan="1" style="width: 25%;">Floors</th>')
	table.insert(output, '<th class="templatePrimary" colspan="1">' .. frame:expandTemplate{title = "RescueTeam", args = {"Kecleon Shop"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" colspan="1" style="width: 25%;">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 shopArg = args["shop_" .. i]
		local spawnrateArg = args["spawnrate_" .. i]
		if not locationArg and not floorsArg and not shopArg and not spawnrateArg 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="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 = "RescueTeam", args = {locationArg}} .. '</td>')
		end
		table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (shopArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (spawnrateArg 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