Module:Shiren 3 Wii Dungeon Traps table

MDFW - The Mystery Dungeon Tree of Information.
Revision as of 19:48, 30 March 2023 by Adkuate (talk | contribs) (Created page with "-------------------------------------------------------------------------------- -- -- Module:Shiren 3 Dungeon Traps table -- -------------------------------------------------------------------------------- local p = {} local mw = require('mw') function p.main(frame) local args = frame.args local themeArg = args["theme"] local output = {} -- Header row table.insert(output, '<table class="templateTheme ' .. frame:preprocess('{{#if:{{lc:' .. themeArg .. '}} | shir...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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
}}

Lua error at line 15: attempt to concatenate local 'themeArg' (a nil value).


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

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

function p.main(frame)
	local args = frame.args
	local themeArg = args["theme"]
	local output = {}
	-- Header row
	table.insert(output, '<table class="templateTheme ' .. frame:preprocess('{{#if:{{lc:' .. themeArg .. '}} | shiren3{{{theme|}}} }}') .. '" style="text-align: center; margin: auto; width: 50%;">')
	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 = "Shiren3", 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 - ' .. (trapArg or "") .. '.png]]</th>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Shiren3", 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