Module:Shiren 3 Wii Dungeon Traps table

MDFW - The Mystery Dungeon Tree of Information.
Revision as of 16:24, 2 April 2023 by Adkuate (talk | contribs)
Jump to navigation Jump to search
Template-info.png Documentation

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

Usage

{{#invoke:Shiren 3 Wii Dungeon Traps table|main 
  | trap_1   = 
  | floors_1 = 
  ...
  | trap_2   = 
  | floors_2 = 
}}

Example

{{#invoke:Shiren 3 Wii Dungeon Traps table|main
  | trap_1   = Immobilize Trap
  | floors_1 = 1 - 3
  | trap_2   = Immobilize Trap
  | floors_2 = 7 - 9
}}
ModelTraps and Floor TilesFloors
EnglishJapanese
Shiren 3 Wii - Immobilize Trap.pngImmobilize TrapScript error: No such module "Shiren 3 Trap Data Cell".
Shiren 3 Wii - Immobilize Trap.pngImmobilize TrapScript error: No such module "Shiren 3 Trap Data Cell".

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

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

function p.main(frame)
	local args = frame.args
	local typeArg = args["type"]
	local output = {}
	-- Header row
	if typeArg then
		table.insert(output, '<table class="templateTheme shiren3' .. frame:preprocess('{{lc:' .. typeArg .. '}}') .. '" style="text-align: center; margin: auto; width: 50%;">')
	else
		table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">')
	end
	table.insert(output, '<tr>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="border-radius: 1rem 0 0 0; width: 10%;">Model</th>')
	table.insert(output, '<th class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "Shiren3Wii", args = {"Traps and Floor Tiles"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="border-radius: 0 1rem 0 0; width: 40%;">Floors</th>')
	table.insert(output, '</tr>')
	table.insert(output, '<tr>')
	table.insert(output, '<th class="templatePrimary" style="width: 25%;">English</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 25%;">Japanese</th>')
	table.insert(output, '</tr>')
	-- Data rows
	for i = 1, 100 do
		local trapArg = args["trap_" .. i]
		local floorArg = args["floor_" .. i]
		if not trapArg and not floorArg then
			break -- exit loop when no more rows are found
		end
		local rowData = {}
		table.insert(rowData, '<tr class="trapsTableRow">')
		table.insert(rowData, '<th class="templatePrimary">[[File:Shiren 3 Wii - ' .. (trapArg or "") .. '.png]]</th>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Shiren3Wii", args = {(trapArg or "")}} .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Shiren 3 Trap Data Cell|shiren3TrapDataCell|name=' .. (trapArg or "") .. '}}') .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (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