Module:Torneko 1 Dungeon Monsters table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--
-- Module:Torneko 1 Dungeon Monsters table
-- Module:Torneko 1 Dungeon Monsters table
--
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 10: Line 10:
function p.main(frame)
function p.main(frame)
local args = frame.args
local args = frame.args
local output = {}
local output = mw.html.create()
local header = mw.html.create()
-- Header row
-- Header row
table.insert(output, '<table class="MDWiki" style="text-align: center; margin: auto; width: 50%;">')
header
table.insert(output, '<tr>')
:tag('tr')
table.insert(output, '<th rowspan="2" style="width: 10%;">Sprite</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Sprite"):done()
table.insert(output, '<th colspan="2">' .. frame:expandTemplate{title = "Torneko1", args = {"Monster"}} .. '</th>')
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "Torneko1", args = {"Monster"}}):done()
table.insert(output, '<th rowspan="2" style="width: 20%;">' .. frame:expandTemplate{title = "Torneko1", args = {"Experience"}} .. '</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "Torneko1", args = {"Experience"}}):done()
table.insert(output, '<th rowspan="2" style="width: 20%;">Floors</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 20%"):wikitext("Floors"):done()
table.insert(output, '</tr>')
:tag('td'):wikitext(recruit)
table.insert(output, '<tr>')
:tag('tr')
table.insert(output, '<th style="width: 25%;">English</th>')
:tag('th'):cssText("width: 25%"):wikitext("English"):done()
table.insert(output, '<th style="width: 25%;">Japanese</th>')
:tag('th'):cssText("width: 25%"):wikitext("Japanese"):done()
table.insert(output, '</tr>')
-- Data rows
-- Cell rows
for i = 1, 100 do
local rows = mw.html.create()
local i = 1
while true do
local row = mw.html.create()
local monsterArg = args["monster_" .. i]
local monsterArg = args["monster_" .. i]
local floorArg = args["floors_" .. i]
local floorArg = args["floors_" .. i]
Line 32: Line 38:
end
end
monsterArg = (monsterArg or "")
row
floorArg = (floorArg or frame:expandTemplate{title = "Research"})
:tag("tr")
:tag("th"):wikitext(frame:expandTemplate{title = "Torneko1Sprite", args = {(monsterArg or ""), size = "50x50px"}}):done()
:tag("td"):wikitext(frame:expandTemplate{title = "Torneko1", args = {(monsterArg or "")}}):done()
:tag("td"):wikitext(data[monsterArg]["ja"])
:tag("td"):wikitext(data[monsterArg]["exp"])
:tag("td"):wikitext(floorsArg or frame:expandTemplate{title = "Research"}):done()
local rowData = {}
rows
table.insert(rowData, '<tr>')
:node(cellArg)
table.insert(rowData, '<th>' .. frame:expandTemplate{title = "Torneko1Sprite", args = {monsterArg}} .. '</th>')
:allDone()
table.insert(rowData, '<td>' .. frame:expandTemplate{title = "Torneko1", args = {monsterArg}} .. '</td>')
table.insert(rowData, '<td>' .. frame:preprocess('{{#invoke:Torneko 1 Monster Data Cell|torneko1MonsterDataCell|name=' .. monsterArg .. '|getVar=ja}}') .. '</td>')
i = i + 1
table.insert(rowData, '<td>' .. frame:preprocess('{{#invoke:Torneko 1 Monster Data Cell|torneko1MonsterDataCell|name=' .. monsterArg .. '|getVar=exp}}') .. '</td>')
table.insert(rowData, '<td>' .. floorArg .. '</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; margin: auto; width: 50%;")
:node(header)
:node(rows)
return tostring(output)
end
end


return p
return p

Revision as of 16:38, 13 April 2024


--------------------------------------------------------------------------------
--
--					Module:Torneko 1 Dungeon Monsters table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local args = frame.args
	local output = mw.html.create()
	local header = mw.html.create()
	
	-- Header row
	header
		:tag('tr')
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Sprite"):done()
			:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "Torneko1", args = {"Monster"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "Torneko1", args = {"Experience"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 20%"):wikitext("Floors"):done()
			:tag('td'):wikitext(recruit)
		:tag('tr')
			:tag('th'):cssText("width: 25%"):wikitext("English"):done()
			:tag('th'):cssText("width: 25%"):wikitext("Japanese"):done()
	
	-- Cell rows
	local rows = mw.html.create()
	local i = 1
	
	while true do
		local row = mw.html.create()
		local monsterArg = args["monster_" .. i]
		local floorArg = args["floors_" .. i]
		
		if not monsterArg and not floorArg then
			break -- exit loop when no more rows are found
		end
		
		row
			:tag("tr")
				:tag("th"):wikitext(frame:expandTemplate{title = "Torneko1Sprite", args = {(monsterArg or ""), size = "50x50px"}}):done()
				:tag("td"):wikitext(frame:expandTemplate{title = "Torneko1", args = {(monsterArg or "")}}):done()
				:tag("td"):wikitext(data[monsterArg]["ja"])
				:tag("td"):wikitext(data[monsterArg]["exp"])
				:tag("td"):wikitext(floorsArg or frame:expandTemplate{title = "Research"}):done()
		
		rows
			:node(cellArg)
			:allDone()
		
		i = i + 1
	end
	
	output
		:tag('table'):addClass("MDWiki"):cssText("text-align: center; margin: auto; width: 50%;")
			:node(header)
			:node(rows)
	return tostring(output)
end

return p