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

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
(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...")
 
mNo edit summary
Line 13: Line 13:
local output = {}
local output = {}
-- Header row
-- Header row
table.insert(output, '<table class="templateTheme ' .. frame:preprocess('{{#if:{{lc:' .. themeArg .. '}} | shiren3{{{theme|}}} }}') .. '" style="text-align: center; margin: auto; width: 50%;">')
if themeArg then
table.insert(output, '<table class="templateTheme shiren3' .. frame:preprocess('{{lc:' .. themeArg .. '}}') .. '" 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, '<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" 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" 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, '<th class="templatePrimary" rowspan="2" style="border-radius: 0 1rem 0 0; width: 40%;">Floors</th>')
table.insert(output, '</tr>')
table.insert(output, '</tr>')
Line 32: Line 36:
local rowData = {}
local rowData = {}
table.insert(rowData, '<tr class="trapsTableRow">')
table.insert(rowData, '<tr class="trapsTableRow">')
table.insert(rowData, '<th class="templatePrimary">[[File:Shiren 3 - ' .. (trapArg or "") .. '.png]]</th>')
table.insert(rowData, '<th class="templatePrimary">[[File:Shiren 3 Wii - ' .. (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: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">' .. frame:preprocess('{{#invoke:Shiren 3 Trap Data Cell|Shiren3TrapDataCell|name=' .. (trapArg or "") .. '}}') .. '</td>')

Revision as of 19:52, 30 March 2023

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: expandTemplate: template "Shiren3" does not exist.


--------------------------------------------------------------------------------
--
--			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
	if themeArg then
		table.insert(output, '<table class="templateTheme shiren3' .. frame:preprocess('{{lc:' .. themeArg .. '}}') .. '" 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 = "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