Module:Shiren 3 Wii 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 11: Line 11:
local args = frame.args
local args = frame.args
local categoryArg = args["category"]
local categoryArg = args["category"]
local themeArg = args["theme"]
local typeArg = args["type"]
local output = {}
local output = {}
-- Header row
-- Header row
if themeArg then
if typeArg then
table.insert(output, '<table class="templateTheme shiren3' .. frame:preprocess('{{lc:' .. themeArg .. '}}') .. '" style="text-align: center; width: 100%;">')
table.insert(output, '<table class="templateTheme shiren3' .. frame:preprocess('{{lc:' .. typeArg .. '}}') .. '" style="text-align: center; width: 100%;">')
else
else
table.insert(output, '<table class="templateTheme" style="text-align: center; width: 100%;">')
table.insert(output, '<table class="templateTheme" style="text-align: center; width: 100%;">')

Revision as of 16:23, 2 April 2023

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
EnglishJapaneseFloorsItem
Frequency
Escape ScrollScript error: No such module "Shiren 3 Item Data Cell".[Research required][Research required]
Light ScrollScript error: No such module "Shiren 3 Item Data Cell".[Research required][Research required]

--------------------------------------------------------------------------------
--
--			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
	if typeArg then
		table.insert(output, '<table class="templateTheme shiren3' .. frame:preprocess('{{lc:' .. typeArg .. '}}') .. '" style="text-align: center; width: 100%;">')
	else
		table.insert(output, '<table class="templateTheme" style="text-align: center; width: 100%;">')
	end
	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: 25%;">English</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 25%;">Japanese</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, '</tr>')
	-- Data rows
	for i = 1, 100 do
		local itemArg = args["item_" .. i]
		local floorArg = args["floor_" .. i]
		local frequencyArg = args["frequency_" .. i]
		if not itemArg and not floorArg and not frequencyArg 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>')
		else
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
		end
		if itemArg then
			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>')
		end
		table.insert(rowData, '<td class="templateSecondary">' .. (floorArg 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