Module:Shiren 3 Wii Dungeon Items table

MDFW - The Mystery Dungeon Tree of Information.
Revision as of 17:12, 24 June 2023 by Adkuate (talk | contribs)
Jump to navigation Jump to search
Template-info.png Documentation

This template generates a list of items present in a dungeon for Shiren the Wanderer 3.

Usage

{{#invoke:Shiren 3 Wii Dungeon Items table|main
  | type        = 
  | category    = 
  | item_1      = 
  ...
  | item_n      = 
}}

Example

{{#invoke:Shiren 3 Wii Dungeon Items table|main
  | type        = past
  | category    = Scroll
  | item_1      = Escape Scroll
  | item_2      = Light Scroll
}}
Shiren 3 Wii - Scroll.png
Scroll
EnglishJapanese
Escape ScrollScript error: No such module "Shiren 3 Item Data Cell".
Light ScrollScript error: No such module "Shiren 3 Item Data Cell".

--------------------------------------------------------------------------------
--
--			Module:Shiren 3 Wii Dungeon Items table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local args = frame.args
	local categoryArg = args["category"]
	local typeArg = args["type"]
	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:Shiren 3 Wii - ' .. frame:preprocess('{{#switch:' .. categoryArg .. ' | Armbands=Armband | Weapons=Weapon | Shields=Shield | Herbs=Herb | Riceballs=Riceball | Monster Meats=Monster Meat | Jars=Jar | Projectiles=Arrows | Scrolls=Scroll | Staves=Staff | Traps=Trap | Miscellaneous=Jar Fragment | Gitan=Gitan Bag | #default={{{category|}}} }}') .. '.png|50x50px]]<br>' .. frame:expandTemplate{title = "Shiren3Wii", 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>')
	table.insert(output, '<th class="templatePrimary" style="width: 50%;">English</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 50%;">Japanese</th>')
	table.insert(output, '</tr>')
	-- Data rows
	for i = 1, 100 do
		local itemArg = args["item_" .. i]
		if not itemArg then
			break -- exit loop when no more rows are found
		end
		local rowData = {}
		table.insert(rowData, '<tr class="itemsTableRow">')
		if itemArg then
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Shiren3Wii", args = {(itemArg or "")}} .. '</td>')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Shiren 3 Item Data Cell|shiren3ItemDataCell|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
		table.insert(rowData, '</tr>')
		table.insert(output, table.concat(rowData))
	end
	table.insert(output, '</table>')
	return table.concat(output)
end

return p