Module:Torneko 1 Dungeon Items table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--
-- Module:Torneko 1 Dungeon Items table
-- Module:Torneko 1 Dungeon Items table
--
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 9: Line 9:


function p.main(frame)
function p.main(frame)
local data = require("Module:Torneko 1 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 output = {}
 
-- Header row
-- Header row
table.insert(output, '<table class="MDWiki" style="text-align: center; width: 100%;">')
header
table.insert(output, '<tr>')
:tag('tr')
if categoryArg then
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "Torneko1Sprite", args = {frame:preprocess('{{#switch:' .. categoryArg .. ' | #default={{{category|}}} }}')}} .. '<br>' .. frame:expandTemplate{title = "Torneko1", args = {(categoryArg or "")}}):done()
table.insert(output, '<th colspan="3" style="height: 5rem;">[[File:Torneko 1 - ' .. frame:preprocess('{{#switch:' .. categoryArg .. ' | Herbs = Herb | Food = Bread | Weapons = Sword | Shields = Shield | Rings = Ring | Scrolls = Scroll | Staves = Staff | Projectiles = Arrow | #default=' .. (categoryArg) .. ' }}') .. '.svg|32x32px|alt=' .. (categoryArg) .. '|' .. (categoryArg) .. ']]<br>' .. frame:expandTemplate{title = "Torneko1", args = {(categoryArg or "")}} .. '</th>')
:tag('tr')
else
:tag('th'):cssText("width: 50%"):wikitext("English"):done()
table.insert(output, '<th colspan="3" style="height: 5rem;">' .. frame:expandTemplate{title = "Research"} .. '</th>')
:tag('th'):cssText("width: 50%"):wikitext("Japanese"):done()
end
table.insert(output, '</tr>')
table.insert(output, '<tr>')
if string.lower(categoryArg) == "gold" then
table.insert(output, '<th style="width: 33%;">Lowest amount</th>')
table.insert(output, '<th style="width: 33%;">Highest ammount</th>')
else
table.insert(output, '<th style="width: 33%;">English</th>')
table.insert(output, '<th style="width: 33%;">Japanese</th>')
end
table.insert(output, '<th style="width: 34%;">Floors</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 lowAmountArg = args["low_amount_" .. i]
 
local highAmountArg = args["high_amount_" .. i]
if not itemArg and not floorArg then
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
break -- exit loop when no more rows are found
end
end
local rowData = {}
table.insert(rowData, '<tr>')
row
if string.lower(categoryArg) == "poké" then
:tag("tr")
table.insert(rowData, '<td>' .. (lowAmountArg or frame:expandTemplate{title = "Research"}) .. '</td>')
:tag("td"):wikitext(frame:expandTemplate{title = "Torneko1", args = {(itemArg or "")}}):done()
table.insert(rowData, '<td>' .. (highAmountArg or frame:expandTemplate{title = "Research"}) .. '</td>')
:tag("td"):wikitext(data[itemArg]["ja"])
else
if itemArg then
rows
table.insert(rowData, '<td>' .. frame:expandTemplate{title = "Torneko1", args = {itemArg}} .. '</td>')
:node(row)
table.insert(rowData, '<td>' .. frame:preprocess('{{#invoke:Torneko 1 Item Data Cell|torneko1ItemDataCell|name=' .. itemArg .. '}}') .. '</td>')
:allDone()
else
table.insert(rowData, '<td>' .. frame:expandTemplate{title = "Research"} .. '</td>')
i = i + 1
table.insert(rowData, '<td>' .. frame:expandTemplate{title = "Research"} .. '</td>')
end
end
table.insert(rowData, '<td>' .. (floorsArg 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("MDWiki"):cssText("text-align: center; width: 100%;")
:node(header)
:node(rows)
return tostring(output)
end
end


return p
return p

Revision as of 21:14, 15 July 2024

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

--------------------------------------------------------------------------------
--
--					Module:Torneko 1 Dungeon Items table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local data = require("Module:Torneko 1 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 = "Torneko1Sprite", args = {frame:preprocess('{{#switch:' .. categoryArg .. ' | #default={{{category|}}} }}')}} .. '<br>' .. frame:expandTemplate{title = "Torneko1", 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 = "Torneko1", args = {(itemArg or "")}}):done()
				:tag("td"):wikitext(data[itemArg]["ja"])
		
		rows
			:node(row)
			:allDone()
		
		i = i + 1
	end
	
	output
		:tag('table'):addClass("MDWiki"):cssText("text-align: center; width: 100%;")
			:node(header)
			:node(rows)
	return tostring(output)
end

return p