Module:Shiren 6 Dungeon Items table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
(Created page with "-------------------------------------------------------------------------------- -- -- Module:Shiren 6 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: cente...")
 
mNo edit summary
Line 36: Line 36:
if itemArg then
if itemArg then
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Shiren6", args = {(itemArg or "")}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Shiren6", args = {(itemArg or "")}} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Shiren 3 Item Data Cell|shiren6ItemDataCell|name=' .. (itemArg or "") .. '}}') .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Shiren 6 Item Data Cell|shiren6ItemDataCell|name=' .. (itemArg or "") .. '}}') .. '</td>')
else
else
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')

Revision as of 20:49, 25 February 2024

Documentation for this module may be created at Module:Shiren 6 Dungeon Items table/doc

--------------------------------------------------------------------------------
--
--			Module:Shiren 6 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 6 - ' .. 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 = "Shiren6", 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 = "Shiren6", args = {(itemArg or "")}} .. '</td>')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Shiren 6 Item Data Cell|shiren6ItemDataCell|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