Module:Rescue Team DX 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
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--
-- Module:Rescue Team Dungeon Items table
-- Module:Rescue Team DX Dungeon Items table
--
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 9: Line 9:


function p.main(frame)
function p.main(frame)
local data = require("Module:Rescue Team DX Item Data Cell")
local metatable = {__index = function () return "" end}
setmetatable(data, metatable)
local args = frame.args
local args = frame.args
local output = mw.html.create()
local header = mw.html.create()
local categoryArg = args["category"]
local categoryArg = args["category"]
local output = {}
 
-- Header row
-- Header row
table.insert(output, '<table class="templateTheme" style="text-align: center; width: 100%; max-width: 33%;">')
header
table.insert(output, '<tr>')
:tag('tr')
if categoryArg then
:tag('th'):attr("colspan", "3"):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {frame:preprocess('{{#switch:' .. categoryArg .. ' | Berry=Oran Berry | Health Drink=Max Elixir | Seed=Reviver Seed | Projectile=Gravelerock | Food=Apple | Gummi=Rainbow Gummi | Equipment=Pecha Scarf | Wonder Orb=Escape Orb | Wand=Switcher Wand | Miscellaneous Item=Evolution Crystal | #default={{{category|}}} }}'), size = "32px"}} .. '<br>' .. frame:expandTemplate{title = "RescueTeamDX", args = {(categoryArg or "")}}):done()
table.insert(output, '<th class="templatePrimary" colspan="4" style="height: 5rem;">[[File:Rescue Team DX - ' .. 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 Box=Link Cable | TMs & HMs=TM | Wonder Orbs=Wonder Orb | Equipment=Scarf | Miscellaneous Items=Key | Exclusive Items=Exclusive Item (44) | #default=' .. categoryArg .. ' }}') .. '.png|alt=' .. categoryArg .. '.|50x50px]]<br>' .. frame:expandTemplate{title = "RescueTeamDX", args = {categoryArg}} .. '</th>')
:tag('tr')
if string.lower(categoryArg) == "poké" then
header
:tag('th'):cssText("width: 33%"):wikitext("Lowest amount"):done()
:tag('th'):cssText("width: 33%"):wikitext("Highest amount"):done()
else
else
table.insert(output, '<th class="templatePrimary" colspan="4" style="height: 5rem;">' .. frame:expandTemplate{title = "Research"} .. '</th>')
header
:tag('th'):cssText("width: 33%"):wikitext("English"):done()
:tag('th'):cssText("width: 33%"):wikitext("Japanese"):done()
end
end
table.insert(output, '</tr>')
header
table.insert(output, '<tr>')
:tag('th'):cssText("width: 34%"):wikitext("Floors"):done()
if categoryArg == "Poké" then
 
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Lowest amount</th>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Highest ammount</th>')
else
table.insert(output, '<th class="templatePrimary" style="width: 25%;">English</th>')
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Japanese</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
-- Data rows
for i = 1, 100 do
local rows = mw.html.create()
local i = 1
while true do
local row = mw.html.create()
local itemArg = args["item_" .. i]
local itemArg = args["item_" .. i]
local lowAmountArg = args["low_amount_" .. i]
local lowAmountArg = args["low_amount_" .. i]
local highAmountArg = args["high_amount_" .. i]
local highAmountArg = args["high_amount_" .. i]
local floorsArg = args["floors_" .. i]
local floorsArg = args["floors_" .. i]
local frequencyArg = args["frequency_" .. i]
 
if not itemArg and not floorsArg and not frequencyArg and not lowAmountArg and not highAmountArg then
if not itemArg and not floorsArg and not lowAmountArg and not highAmountArg then
break -- exit loop when no more rows are found
break -- exit loop when no more rows are found
end
end
local rowData = {}
table.insert(rowData, '<tr class="itemsTableRow">')
row
if categoryArg == "Poké" then
:tag("tr")
table.insert(rowData, '<td class="templateSecondary">' .. (lowAmountArg or frame:expandTemplate{title = "Research"}) .. '</td>')
if string.lower(categoryArg) == "poké" then
table.insert(rowData, '<td class="templateSecondary">' .. (highAmountArg or frame:expandTemplate{title = "Research"}) .. '</td>')
row
:tag("td"):wikitext((lowAmountArg or frame:expandTemplate{title = "Research"})):done()
:tag("td"):wikitext((highAmountArg or frame:expandTemplate{title = "Research"})):done()
else
else
if itemArg then
row
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {itemArg}} .. '</td>')
:tag("td"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {(itemArg or "")}}):done()
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team DX Item Data Cell|rescueTeamDXItemDataCell|name=' .. itemArg .. '}}') .. '</td>')
:tag("td"):wikitext(data[itemArg]["ja"]):done()
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>')
row
table.insert(rowData, '<td class="templateSecondary">' .. (frequencyArg or frame:expandTemplate{title = "Research"}) .. '</td>')
:tag("td"):wikitext((floorsArg or frame:expandTemplate{title = "Research"})):done()
table.insert(rowData, '</tr>')
 
table.insert(output, table.concat(rowData))
rows
:node(row)
:allDone()
i = i + 1
end
end
table.insert(output, '</table>')
return table.concat(output)
output
:tag('table'):addClass("wikitable"):cssText("text-align: center; width: 100%;")
:node(header)
:node(rows)
return tostring(output)
end
end


return p
return p

Latest revision as of 09:29, 26 January 2025

Template-info.png Documentation

This template generates a list of items present in a dungeon for Pokémon Mystery Dungeon: Rescue Team DX.

Usage

{{#invoke:Rescue Team DX Dungeon Items table|main
  | category    = 
  | item_1      = 
  | floors_1    = 
  ...
  | item_n      = 
  | floors_n    = 
}}

Example

{{#invoke:Rescue Team DX Dungeon Items table|main
  | category    = Berry
  | item_1      = Oran Berry
  | floors_1    = 1 - 3
}}
Oran Berry's sprite.
Berry
EnglishJapaneseFloors
Oran Berryオレンのみ1 - 3

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

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

function p.main(frame)
	local data = require("Module:Rescue Team DX Item Data Cell")
	local metatable = {__index = function () return "" end}
	setmetatable(data, metatable)
	local args = frame.args
	
	local output = mw.html.create()
	local header = mw.html.create()
	local categoryArg = args["category"]

	-- Header row
	header
		:tag('tr')
			:tag('th'):attr("colspan", "3"):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {frame:preprocess('{{#switch:' .. categoryArg .. ' | Berry=Oran Berry | Health Drink=Max Elixir | Seed=Reviver Seed | Projectile=Gravelerock | Food=Apple | Gummi=Rainbow Gummi | Equipment=Pecha Scarf | Wonder Orb=Escape Orb | Wand=Switcher Wand | Miscellaneous Item=Evolution Crystal | #default={{{category|}}} }}'), size = "32px"}} .. '<br>' .. frame:expandTemplate{title = "RescueTeamDX", args = {(categoryArg or "")}}):done()
		:tag('tr')
	if string.lower(categoryArg) == "poké" then
		header
			:tag('th'):cssText("width: 33%"):wikitext("Lowest amount"):done()
			:tag('th'):cssText("width: 33%"):wikitext("Highest amount"):done()
	else
		header
			:tag('th'):cssText("width: 33%"):wikitext("English"):done()
			:tag('th'):cssText("width: 33%"):wikitext("Japanese"):done()
	end
	header
		:tag('th'):cssText("width: 34%"):wikitext("Floors"):done()

	-- Data rows
	local rows = mw.html.create()
	local i = 1
	
	while true do
		local row = mw.html.create()
		local itemArg = args["item_" .. i]
		local lowAmountArg = args["low_amount_" .. i]
		local highAmountArg = args["high_amount_" .. i]
		local floorsArg = args["floors_" .. i]

		if not itemArg and not floorsArg and not lowAmountArg and not highAmountArg then
			break -- exit loop when no more rows are found
		end
		
		row
			:tag("tr")
		if string.lower(categoryArg) == "poké" then
			row
				:tag("td"):wikitext((lowAmountArg or frame:expandTemplate{title = "Research"})):done()
				:tag("td"):wikitext((highAmountArg or frame:expandTemplate{title = "Research"})):done()
		else
			row
				:tag("td"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {(itemArg or "")}}):done()
				:tag("td"):wikitext(data[itemArg]["ja"]):done()
		end
		row
			:tag("td"):wikitext((floorsArg or frame:expandTemplate{title = "Research"})):done()

		rows
			:node(row)
			:allDone()
		
		i = i + 1
	end
	
	output
		:tag('table'):addClass("wikitable"):cssText("text-align: center; width: 100%;")
			:node(header)
			:node(rows)
	return tostring(output)
end

return p