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
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--
-- Module:Shiren 3 Wii Dungeon Items table
-- Module:Shiren 3 Wii Dungeon Items table
--
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 9: Line 9:


function p.main(frame)
function p.main(frame)
local data = require("Module:Shiren 3 Wii 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 typeArg = args["type"]
 
local output = {}
-- Header row
-- Header row
if typeArg then
header
table.insert(output, '<table class="templateTheme shiren3' .. frame:preprocess('{{lc:' .. typeArg .. '}}') .. '" style="text-align: center; width: 100%;">')
:tag('tr')
else
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "Shiren3WiiSprite", args = {frame:preprocess('{{#switch:' .. categoryArg .. ' | Projectiles|Projectile=Arrow | Miscellaneous=Jar Fragment | #default={{{category|}}} }}')}} .. '<br>' .. frame:expandTemplate{title = "Shiren3Wii", args = {(categoryArg or "")}}):done()
table.insert(output, '<table class="templateTheme" style="text-align: center; width: 100%;">')
:tag('tr')
end
:tag('th'):cssText("width: 50%"):wikitext("English"):done()
table.insert(output, '<tr>')
:tag('th'):cssText("width: 50%"):wikitext("Japanese"):done()
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
-- 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 floorArg = args["floor_" .. i]
 
local frequencyArg = args["frequency_" .. i]
if not itemArg and not floorArg then
if not itemArg and not floorArg and not frequencyArg 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">')
if itemArg then
row
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Shiren3Wii", args = {(itemArg or "")}} .. '</td>')
:tag("tr")
else
:tag("td"):wikitext(frame:expandTemplate{title = "Shiren3Wii" .. data[itemArg]["character"], args = {(itemArg or "")}}):done()
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
:tag("td"):wikitext(data[itemArg]["ja"])
end
if itemArg then
rows
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Shiren 3 Item Data Cell|shiren3ItemDataCell|name=' .. (itemArg or "") .. '}}') .. '</td>')
:node(row)
else
:allDone()
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
end
i = i + 1
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
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:08, 26 January 2025

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
}}
Scroll's sprite.
Scroll
EnglishJapanese
Escape Scroll脱出の巻物
Light Scrollあかりの巻物

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

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

function p.main(frame)
	local data = require("Module:Shiren 3 Wii 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", "2"):wikitext(frame:expandTemplate{title = "Shiren3WiiSprite", args = {frame:preprocess('{{#switch:' .. categoryArg .. ' | Projectiles|Projectile=Arrow | Miscellaneous=Jar Fragment | #default={{{category|}}} }}')}} .. '<br>' .. frame:expandTemplate{title = "Shiren3Wii", args = {(categoryArg or "")}}):done()
		:tag('tr')
			:tag('th'):cssText("width: 50%"):wikitext("English"):done()
			:tag('th'):cssText("width: 50%"):wikitext("Japanese"):done()
	
	-- Data rows
	local rows = mw.html.create()
	local i = 1
	
	while true do
		local row = mw.html.create()
		local itemArg = args["item_" .. i]

		if not itemArg and not floorArg then
			break -- exit loop when no more rows are found
		end
		
		row
			:tag("tr")
				:tag("td"):wikitext(frame:expandTemplate{title = "Shiren3Wii" .. data[itemArg]["character"], args = {(itemArg or "")}}):done()
				:tag("td"):wikitext(data[itemArg]["ja"])
		
		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