Module:Etrian 2 Dungeon Monsters table

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
Template-info.png Documentation

This template generates a list of monsters present in a dungeon for Etrian Mystery Dungeon 2.

Usage

{{#invoke:Etrian 2 Dungeon Monsters table|main
  | monster_1 = 
  | floor_1   = 
  ...
  | monster_n = 
  | floor_n   = 
}}

Example

{{#invoke:Etrian 2 Dungeon Monsters table|main
  | monster_1 = Woodfly
  | floor_1   = 1 - 3
  | monster_2 = Grasseater
  | floor_2   = 1 - 3
  | monster_3 = Tree Rat
  | floor_3   = 1 - 3
}}
ModelMonstersExperienceFloors
EnglishJapanese
Woodfly's model.Woodflyシンリンチョウ7201 - 3
Grasseater's model.Grasseaterグラスイーター1,8351 - 3
Tree Rat's model.Tree Rat森ネズミ3401 - 3

--------------------------------------------------------------------------------
--
--					Module:Etrian 2 Dungeon Monsters table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local args = frame.args
	local output = {}
	-- Header row
	table.insert(output, '<table class="wikitable" style="text-align: center; margin: auto; width: 50%;">')
	table.insert(output, '<tr>')
	table.insert(output, '<th rowspan="2" style="width: 10%;">Model</th>')
	table.insert(output, '<th colspan="2">' .. frame:expandTemplate{title = "Etrian2", args = {"Monsters"}} .. '</th>')
	table.insert(output, '<th rowspan="2" style="width: 20%;">' .. frame:expandTemplate{title = "Etrian2", args = {"Experience"}} .. '</th>')
	table.insert(output, '<th rowspan="2" style="width: 20%;">Floors</th>')
	table.insert(output, '</tr>')
	table.insert(output, '<tr>')
	table.insert(output, '<th style="width: 25%;">English</th>')
	table.insert(output, '<th style="width: 25%;">Japanese</th>')
	table.insert(output, '</tr>')
	-- Data rows
	for i = 1, 100 do
		local monsterArg = args["monster_" .. i]
		local floorArg = args["floor_" .. i]
		if not monsterArg and not floorArg then
			break -- exit loop when no more rows are found
		end
		local rowData = {}
		table.insert(rowData, '<tr>')
		table.insert(rowData, '<th>' .. frame:expandTemplate{title = "Etrian2Model", args = {(monsterArg or "")}} .. '</th>')
		table.insert(rowData, '<td>' .. frame:expandTemplate{title = "Etrian2", args = {(monsterArg or "")}} .. '</td>')
		table.insert(rowData, '<td>' .. frame:preprocess('{{#invoke:Etrian 2 Monster Data Cell|etrian2MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=ja}}') .. '</td>')
		table.insert(rowData, '<td>' .. frame:preprocess('{{#invoke:Etrian 2 Monster Data Cell|etrian2MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=exp}}') .. '</td>')
		table.insert(rowData, '<td>' .. (floorArg or "") .. '</td>')
		table.insert(rowData, '</tr>')
		table.insert(output, table.concat(rowData))
	end
	table.insert(output, '</table>')
	return table.concat(output)
end

return p