Module:Shiren 3 Wii Dungeon Monsters table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--
-- Module:Shiren 3 Wii Dungeon Monsters table
-- Module:Shiren 3 Wii Dungeon Monsters table
--
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 9: Line 9:


function p.main(frame)
function p.main(frame)
local data = require("Module:Shiren 3 Wii Monster Data Cell")
local metatable = {__index = function () return "" end}
setmetatable(data, metatable)
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="templateTheme" style="text-align: center; margin: auto; width: 50%;">')
header
table.insert(output, '<tr>')
:tag('tr')
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">Model</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Model"):done()
table.insert(output, '<th class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "Shiren3Wii", args = {"Monsters"}} .. '</th>')
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "Shiren3Wii", args = {"Monster"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "Shiren3Wii", args = {"Attribute"}} .. '</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "Shiren3Wii", args = {"Experience"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "Shiren3Wii", args = {"Experience"}} .. '</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "Shiren3Wii", args = {"Monster Element"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 20%;">Floors</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 20%"):wikitext("Floors"):done()
table.insert(output, '</tr>')
:tag('tr')
table.insert(output, '<tr>')
:tag('th'):cssText("width: 25%"):wikitext("English"):done()
table.insert(output, '<th class="templatePrimary" style="width: 25%;">English</th>')
:tag('th'):cssText("width: 25%"):wikitext("Japanese"):done()
table.insert(output, '<th class="templatePrimary" style="width: 25%;">Japanese</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 monsterArg = args["monster_" .. i]
local monsterArg = args["monster_" .. i]
local floorArg = args["floor_" .. i]
local floorsArg = args["floors_" .. i]
if not monsterArg and not floorArg then
if not monsterArg and not floorsArg 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="monstersTableRow">')
row
table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "Shiren3Model", args = {(monsterArg or "")}} .. '</th>')
:tag("tr")
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Shiren3Wii", args = {(monsterArg or "")}} .. '</td>')
:tag("th"):wikitext(frame:expandTemplate{title = "Shiren3WiiModel", args = {(monsterArg or ""), size = "50x50px"}}):done()
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Shiren 3 Monster Data Cell|shiren3MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=ja}}') .. '</td>')
:tag("td"):wikitext(frame:expandTemplate{title = "Shiren3Wii", args = {(monsterArg or "")}}):done()
table.insert(rowData, '<td class="templateSecondary" style="' .. frame:preprocess('{{#switch:{{#invoke:Shiren 3 Monster Data Cell|shiren3MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=type}} | Water=background: #0000FF!important; color: white; | Nature=background: #228B22!important; | Fire=background: #FF0000!important; | Thunder=background: #FFFF00!important; | Shadow=background: #000000!important; color: white; | Earth=background: #8B4513!important; | Spirit=background: #FF69B4!important; | Illusion=background: #8A2BE2!important; }}') .. '">' .. frame:preprocess('{{#invoke:Shiren 3 Monster Data Cell|shiren3MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=type}}') .. '</td>')
:tag("td"):wikitext(data[monsterArg]["ja"])
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Shiren 3 Monster Data Cell|shiren3MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=exp}}') .. '</td>')
:tag("td"):wikitext(data[monsterArg]["exp"])
table.insert(rowData, '<td class="templateSecondary">' .. (floorArg or "") .. '</td>')
:tag("td"):wikitext(data[monsterArg]["type"]):cssText("background-color: " .. frame:preprocess('{{#switch: {{lc: ' .. (data[monsterArg]["type"] or "") .. '}} | water=#0000FF!important; color: white | steel=#696969!important; color: black | nature=#228B22!important | fire=#FF0000!important | thunder=#FFFF00!important | shadow=#000000!important; color: white | earth=#8B4513!important | spirit=#FF69B4!important | illusion=#8A2BE2!important | special=#FF8C00!important }}') .. ";")
table.insert(rowData, '</tr>')
:tag("td"):wikitext(floorsArg or frame:expandTemplate{title = "Research"}):done()
table.insert(output, table.concat(rowData))
rows
:node(row)
:allDone()
i = i + 1
end
end
table.insert(output, '</table>')
return table.concat(output)
output
:tag('table'):addClass("wikitable"):cssText("text-align: center; margin: auto; width: 50%;")
:node(header)
:node(rows)
return tostring(output)
end
end


return p
return p

Latest revision as of 09:09, 26 January 2025

Template-info.png Documentation

This template generates a list of monsters present in a dungeon for Shiren the Wanderer 3: The Sleeping Princess and the Karakuri Mansion.

Usage

{{#invoke:Shiren 3 Wii Dungeon Monsters table|main
  | type      =
  | monster_1 = 
  | floor_1   = 
  ...
  | monster_n = 
  | floor_n   = 
}}

Example

{{#invoke:Shiren 3 Wii Dungeon Monsters table|main
  | type      = past
  | monster_1 = Mamel
  | floor_1   = 1 - 3
  | monster_2 = Balsam Bug
  | floor_2   = 1 - 3
  | monster_3 = Mouse Minion
  | floor_3   = 1 - 3
}}
ModelMonsterExperienceMonster ElementFloors
EnglishJapanese
Mamel's model.Mamelマムル2Water[Research required]
Balsam Bug's model.Balsam Bugホウセンムシ3Fire[Research required]
Mouse Minion's model.Mouse Minionねずみ子分4Water[Research required]

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

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

function p.main(frame)
	local data = require("Module:Shiren 3 Wii Monster 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()
	
	-- Header row
	header
		:tag('tr')
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Model"):done()
			:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "Shiren3Wii", args = {"Monster"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "Shiren3Wii", args = {"Experience"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "Shiren3Wii", args = {"Monster Element"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 20%"):wikitext("Floors"):done()
		:tag('tr')
			:tag('th'):cssText("width: 25%"):wikitext("English"):done()
			:tag('th'):cssText("width: 25%"):wikitext("Japanese"):done()
	
	-- Data rows
	local rows = mw.html.create()
	local i = 1
	
	while true do
		local row = mw.html.create()
		local monsterArg = args["monster_" .. i]
		local floorsArg = args["floors_" .. i]
		
		if not monsterArg and not floorsArg then
			break -- exit loop when no more rows are found
		end
		
		row
			:tag("tr")
				:tag("th"):wikitext(frame:expandTemplate{title = "Shiren3WiiModel", args = {(monsterArg or ""), size = "50x50px"}}):done()
				:tag("td"):wikitext(frame:expandTemplate{title = "Shiren3Wii", args = {(monsterArg or "")}}):done()
				:tag("td"):wikitext(data[monsterArg]["ja"])
				:tag("td"):wikitext(data[monsterArg]["exp"])
				:tag("td"):wikitext(data[monsterArg]["type"]):cssText("background-color: " .. frame:preprocess('{{#switch: {{lc: ' .. (data[monsterArg]["type"] or "") .. '}} | water=#0000FF!important; color: white | steel=#696969!important; color: black | nature=#228B22!important | fire=#FF0000!important | thunder=#FFFF00!important | shadow=#000000!important; color: white | earth=#8B4513!important | spirit=#FF69B4!important | illusion=#8A2BE2!important | special=#FF8C00!important }}') .. ";")
				: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; margin: auto; width: 50%;")
			:node(header)
			:node(rows)
	return tostring(output)
end

return p