Module:Torneko 1 Dungeon Traps table: Difference between revisions
Jump to navigation
Jump to search
No edit summary Tag: Reverted |
Tag: Undo |
||
Line 1: | Line 1: | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- | -- | ||
-- | -- Module:Torneko 1 Dungeon Traps table | ||
-- | -- | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
Line 9: | Line 9: | ||
function p.main(frame) | function p.main(frame) | ||
local args = frame.args | local args = frame.args | ||
local output = {} | |||
local output = | |||
-- Header row | -- Header row | ||
table.insert(output, '<table class="MDWiki" style="text-align: center; margin: auto; width: 50%;">') | |||
table.insert(output, '<tr>') | |||
table.insert(output, '<th rowspan="2" style="width: 25%;">Sprite</th>') | |||
table.insert(output, '<th colspan="2">' .. frame:expandTemplate{title = "Torneko1", args = {"Traps and Floor Tiles"}} .. '</th>') | |||
table.insert(output, '<th rowspan="2" style="width: 25%;">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 | -- Data rows | ||
for i = 1, 100 do | |||
local trapArg = args["trap_" .. i] | |||
local floorsArg = args["floors_" .. i] | |||
if not trapArg and not floorsArg then | |||
local trapArg = args[" | |||
local | |||
if not trapArg and not | |||
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>') | |||
table.insert(rowData, '<th>[[File:Torneko 1 - ' .. (trapArg or "") .. '.png|alt=' .. (trapArg or "") .. ']]</th>') | |||
table.insert(rowData, '<td>' .. frame:expandTemplate{title = "Torneko1", args = {(trapArg or "")}} .. '</td>') | |||
table.insert(rowData, '<td>' .. frame:preprocess('{{#invoke:Torneko 1 Trap Data Cell|torneko1TrapDataCell|name=' .. (trapArg or "") .. '}}') .. '</td>') | |||
table.insert(rowData, '<td>' .. (floorsArg or frame:expandTemplate{title = "Research"}) .. '</td>') | |||
table.insert(rowData, '</tr>') | |||
table.insert(output, table.concat(rowData)) | |||
end | end | ||
table.insert(output, '</table>') | |||
return table.concat(output) | |||
return | |||
end | end | ||
return p | return p |
Revision as of 20:38, 23 June 2024
Documentation for this module may be created at Module:Torneko 1 Dungeon Traps table/doc
--------------------------------------------------------------------------------
--
-- Module:Torneko 1 Dungeon Traps table
--
--------------------------------------------------------------------------------
local p = {}
local mw = require('mw')
function p.main(frame)
local args = frame.args
local output = {}
-- Header row
table.insert(output, '<table class="MDWiki" style="text-align: center; margin: auto; width: 50%;">')
table.insert(output, '<tr>')
table.insert(output, '<th rowspan="2" style="width: 25%;">Sprite</th>')
table.insert(output, '<th colspan="2">' .. frame:expandTemplate{title = "Torneko1", args = {"Traps and Floor Tiles"}} .. '</th>')
table.insert(output, '<th rowspan="2" style="width: 25%;">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 trapArg = args["trap_" .. i]
local floorsArg = args["floors_" .. i]
if not trapArg and not floorsArg then
break -- exit loop when no more rows are found
end
local rowData = {}
table.insert(rowData, '<tr>')
table.insert(rowData, '<th>[[File:Torneko 1 - ' .. (trapArg or "") .. '.png|alt=' .. (trapArg or "") .. ']]</th>')
table.insert(rowData, '<td>' .. frame:expandTemplate{title = "Torneko1", args = {(trapArg or "")}} .. '</td>')
table.insert(rowData, '<td>' .. frame:preprocess('{{#invoke:Torneko 1 Trap Data Cell|torneko1TrapDataCell|name=' .. (trapArg or "") .. '}}') .. '</td>')
table.insert(rowData, '<td>' .. (floorsArg or frame:expandTemplate{title = "Research"}) .. '</td>')
table.insert(rowData, '</tr>')
table.insert(output, table.concat(rowData))
end
table.insert(output, '</table>')
return table.concat(output)
end
return p