Module:Rescue Team Dungeon Items table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 22: Line 22:
table.insert(output, '</tr>')
table.insert(output, '</tr>')
table.insert(output, '<tr>')
table.insert(output, '<tr>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">English</th>')
if categoryArg == "Poké" then
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Japanese</th>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">English</th>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Japanese</th>')
else
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Lowest amount</th>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Highest ammount</th>')
end
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Floors</th>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Floors</th>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Item<br>Frequency</th>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Item<br>Frequency</th>')
Line 30: Line 35:
for i = 1, 100 do
for i = 1, 100 do
local itemArg = args["item_" .. i]
local itemArg = args["item_" .. i]
local lowAmountArg = args["low_amount"]
local highAmountArg = args["high_amount"]
local floorsArg = args["floors_" .. i]
local floorsArg = args["floors_" .. i]
local frequencyArg = args["frequency_" .. i]
local frequencyArg = args["frequency_" .. i]
Line 37: Line 44:
local rowData = {}
local rowData = {}
table.insert(rowData, '<tr class="itemsTableRow">')
table.insert(rowData, '<tr class="itemsTableRow">')
if categoryArg == "Poké" then
if itemArg then
table.insert(rowData, '<td class="templateSecondary">' .. (lowAmountArg or "") .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeam", args = {(itemArg or "")}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. (highAmountArg or "") .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Item Data Cell|rescueTeamItemDataCell|name=' .. (itemArg or "") .. '}}') .. '</td>')
else
else
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
if itemArg then
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeam", args = {(itemArg or "")}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Item Data Cell|rescueTeamItemDataCell|name=' .. (itemArg or "") .. '}}') .. '</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
end
end
table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or frame:expandTemplate{title = "Research"}) .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or frame:expandTemplate{title = "Research"}) .. '</td>')

Revision as of 08:59, 23 July 2023

Documentation for this module may be created at Module:Rescue Team Dungeon Items table/doc

--------------------------------------------------------------------------------
--
--			Module:Rescue Team Dungeon Items table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local args = frame.args
	local categoryArg = args["category"]
	local output = {}
	-- Header row
	table.insert(output, '<table class="templateTheme" style="text-align: center; width: 100%;">')
	table.insert(output, '<tr>')
	if categoryArg then
		table.insert(output, '<th class="templatePrimary" colspan="4" style="border-radius: 1rem 1rem 0 0; height:7.5rem;">[[File:Rescue Team - ' .. frame:preprocess('{{#switch:' .. categoryArg .. ' | Berries=Oran Berry | Health Drinks=Health Drink | Seeds=Seed | Projectiles=Gravelerock | Food=Apple | Gummis=Clear Gummi | Recruitment Items=Key | Evolution Items=Link Cable | TMs & HMs=TM | Wonder Orbs=Wonder Orb | Equipment=Scarf | Miscellaneous Items=Key | Exclusive Items=Exclusive Item (44) | #default=' .. (categoryArg) .. ' }}') .. '.png]]<br>' .. frame:expandTemplate{title = "RescueTeam", args = {(categoryArg or "")}} .. '</th>')
	else
		table.insert(output, '<th class="templatePrimary" colspan="4" style="border-radius: 1rem 1rem 0 0; height:7.5rem;">' .. frame:expandTemplate{title = "Research"} .. '</th>')
	end
	table.insert(output, '</tr>')
	table.insert(output, '<tr>')
	if categoryArg == "Poké" then
		table.insert(output, '<th class="templatePrimary" style="width: 25%;">English</th>')
		table.insert(output, '<th class="templatePrimary" style="width: 25%;">Japanese</th>')
	else
		table.insert(output, '<th class="templatePrimary" style="width: 25%;">Lowest amount</th>')
		table.insert(output, '<th class="templatePrimary" style="width: 25%;">Highest ammount</th>')
	end
	table.insert(output, '<th class="templatePrimary" style="width: 25%;">Floors</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 25%;">Item<br>Frequency</th>')
	table.insert(output, '</tr>')
	-- Data rows
	for i = 1, 100 do
		local itemArg = args["item_" .. i]
		local lowAmountArg = args["low_amount"]
		local highAmountArg = args["high_amount"]
		local floorsArg = args["floors_" .. i]
		local frequencyArg = args["frequency_" .. i]
		if not itemArg and not floorsArg and not frequencyArg then
			break -- exit loop when no more rows are found
		end
		local rowData = {}
		table.insert(rowData, '<tr class="itemsTableRow">')
		if categoryArg == "Poké" then
			table.insert(rowData, '<td class="templateSecondary">' .. (lowAmountArg or "") .. '</td>')
			table.insert(rowData, '<td class="templateSecondary">' .. (highAmountArg or "") .. '</td>')
		else
			if itemArg then
				table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeam", args = {(itemArg or "")}} .. '</td>')
				table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team Item Data Cell|rescueTeamItemDataCell|name=' .. (itemArg or "") .. '}}') .. '</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
		end
		table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (frequencyArg 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