Module:Shiren 1 DS 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 the same user not shown)
Line 13: Line 13:
setmetatable(data, metatable)
setmetatable(data, metatable)
local args = frame.args
local args = frame.args
 
local output = mw.html.create()
local output = mw.html.create()
local header = mw.html.create()
local header = mw.html.create()
Line 20: Line 20:
-- Header row
-- Header row
header
header
:tag('tr')
:tag('tr'):done()
:tag('th'):attr("colspan", "3"):wikitext(frame:expandTemplate{title = "Shiren1DSSprite", args = {frame:preprocess('{{#switch:' .. categoryArg .. ' | Riceballs=Riceball | Projectile=Arrows | Miscellaneous=Jar Fragment | Gitan=Gitan Bag | #default={{{category|}}} }}')}} .. '<br>' .. frame:expandTemplate{title = "Shiren1DS", args = {(categoryArg or "")}}):done()
:tag('th'):attr("colspan", "3"):wikitext(frame:expandTemplate{title = "Shiren1DSSprite", args = {frame:preprocess('{{#switch:' .. categoryArg .. ' | Riceballs=Riceball | Projectile=Arrows | Miscellaneous=Jar Fragment | #default={{{category|}}} }}'), size = "32x32px"}} .. '<br>' .. frame:expandTemplate{title = "Shiren1DS", args = {(categoryArg or "")}}):done()
:tag('tr')
:tag('tr'):done()
 
if string.lower(categoryArg) == "gitan" then
if string.lower(categoryArg) == "gitan" then
header
header
Line 32: Line 33:
:tag('th'):cssText("width: 33%"):wikitext("Japanese"):done()
:tag('th'):cssText("width: 33%"):wikitext("Japanese"):done()
end
end
header
header
:tag('th'):cssText("width: 34%"):wikitext("Floors"):done()
:tag('th'):cssText("width: 34%"):wikitext("Floors"):done()
Line 38: Line 40:
local rows = mw.html.create()
local rows = mw.html.create()
local i = 1
local i = 1
 
while true do
while true do
local row = mw.html.create()
local row = mw.html.create()
Line 51: Line 53:


row
row
:tag("tr")
:tag("tr"):done()
 
if string.lower(categoryArg) == "gitan" then
if string.lower(categoryArg) == "gitan" then
row
row
Line 57: Line 60:
:tag("td"):wikitext((highAmountArg or frame:expandTemplate{title = "Research"})):done()
:tag("td"):wikitext((highAmountArg or frame:expandTemplate{title = "Research"})):done()
else
else
if itemArg:lower() == 'riceball (item)' then
if itemArg:lower() == 'riceball (item)' or itemArg:lower() == 'riceball' then
itemArg = 'Riceball (item)|Riceball'
itemArgs = { 'Riceball (item)', 'Riceball' }
else
itemArgs = { (itemArg or "") }
end
end


row
row
:tag("td"):wikitext(frame:expandTemplate{title = "Shiren1DS", args = {(itemArg or "")}}):done()
:tag("td"):wikitext(frame:expandTemplate{title = "Shiren1DS", args = itemArgs}):done()
:tag("td"):wikitext(data[itemArg]["ja"]):done()
:tag("td"):wikitext(data[itemArg]["ja"]):done()
end
end
row
row
:tag("td"):wikitext((floorsArg or frame:expandTemplate{title = "Research"})):done()
:tag("td"):wikitext((floorsArg or frame:expandTemplate{title = "Research"})):done()
Line 74: Line 80:
i = i + 1
i = i + 1
end
end
 
output
output
:tag('table'):addClass("MDWiki"):cssText("text-align: center; width: 100%;")
:tag('table'):addClass("wikitable"):cssText("text-align: center; width: 100%;")
:node(header)
:node(header)
:node(rows)
:node(rows)

Latest revision as of 09:30, 26 January 2025

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

--------------------------------------------------------------------------------
--
--					Module:Shiren 1 DS Dungeon Items table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local data = require("Module:Shiren 1 DS 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'):done()
			:tag('th'):attr("colspan", "3"):wikitext(frame:expandTemplate{title = "Shiren1DSSprite", args = {frame:preprocess('{{#switch:' .. categoryArg .. ' | Riceballs=Riceball | Projectile=Arrows | Miscellaneous=Jar Fragment | #default={{{category|}}} }}'), size = "32x32px"}} .. '<br>' .. frame:expandTemplate{title = "Shiren1DS", args = {(categoryArg or "")}}):done()
		:tag('tr'):done()

	if string.lower(categoryArg) == "gitan" 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"):done()

		if string.lower(categoryArg) == "gitan" then
			row
				:tag("td"):wikitext((lowAmountArg or frame:expandTemplate{title = "Research"})):done()
				:tag("td"):wikitext((highAmountArg or frame:expandTemplate{title = "Research"})):done()
		else
			if itemArg:lower() == 'riceball (item)' or itemArg:lower() == 'riceball' then
				itemArgs = { 'Riceball (item)', 'Riceball' }
			else
				itemArgs = { (itemArg or "") }
			end

			row
				:tag("td"):wikitext(frame:expandTemplate{title = "Shiren1DS", args = itemArgs}):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