Module:Sandbox: Difference between revisions
Jump to navigation
Jump to search
Deleca7755 (talk | contribs) No edit summary |
Deleca7755 (talk | contribs) (I'm stupid apparently and there's an extra td for some reason but It should be better now) |
||
Line 9: | Line 9: | ||
function p.main(frame) | function p.main(frame) | ||
local data = | local data = require("Module:Sandbox/test") | ||
local metatable = {__index = function () return "" end} | |||
setmetatable(data, metatable) | |||
local args = frame.args | local args = frame.args | ||
local output = | |||
local output = mw.html.create() | |||
local header = mw.html.create() | |||
-- Header row | -- Header row | ||
header | |||
:tag('tr') | |||
:tag('th'):addClass("templatePrimary"):attr("rowspan", "2" ):cssText("width: 10%"):wikitext("Sprite"):done() | |||
:tag('th'):addClass("templatePrimary"):attr("colspan", "2" ):cssText("width: 10%"):wikitext("{{RescueTeamDX|Pokémon}}"):done() | |||
:tag('th'):addClass("templatePrimary"):attr("colspan", "2" ):attr("rowspan", "2" ):cssText("width: 20%"):wikitext("{{RescueTeamDX|Types}}"):done() | |||
:tag('th'):addClass("templatePrimary"):attr("rowspan", "2" ):cssText("width: 10%"):wikitext("{{RescueTeamDX|Level}}"):done() | |||
:tag('th'):addClass("templatePrimary"):attr("rowspan", "2" ):cssText("width: 10%"):wikitext("Floors"):done() | |||
:tag('td'):wikitext(recruit) | |||
:tag('tr') | |||
:tag('th'):addClass("templatePrimary"):cssText("width: 25%"):wikitext("English"):done() | |||
:tag('th'):addClass("templatePrimary"):cssText("width: 25%"):wikitext("Japanese"):done() | |||
-- Data rows | -- Data rows | ||
local rows = mw.html.create() | |||
for i = 1, 150 do | for i = 1, 150 do | ||
local monsterArg = args[" | local row = mw.html.create() | ||
local monsterArg = args["pokemon_" .. i] | |||
local floorsArg = args["floors_" .. i] | local floorsArg = args["floors_" .. i] | ||
local levelArg = args["level_" .. i] | local levelArg = args["level_" .. i] | ||
Line 33: | Line 39: | ||
break -- exit loop when no more rows are found | break -- exit loop when no more rows are found | ||
end | end | ||
local typeOne = data[monsterArg | local typeOne = data[monsterArg]["type1"] or "" | ||
local typeTwo = data[monsterArg | local typeTwo = data[monsterArg]["type2"] or "" | ||
row | |||
:tag("tr"):addClass("monstersTableRow"):done() | |||
:tag("th"):addClass("templatePrimary"):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "50x50px"}}):done() | |||
:tag("td"):addClass("templateSecondary"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}}) | |||
:tag("td"):addClass("templateSecondary"):wikitext(data[monsterArg]["ja"]) | |||
if typeTwo == nil or typeTwo == '' then | if typeTwo == nil or typeTwo == '' then | ||
row | |||
:tag('td'):addClass("templatePrimary"):attr("colspan", "2" ):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}}):done() | |||
else | else | ||
row | |||
:tag('td'):addClass("templatePrimary"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}}):done() | |||
:tag('td'):addClass("templatePrimary"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeTwo}}):done() | |||
end | end | ||
row | |||
:tag("td"):addClass("templateSecondary"):wikitext(levelArg or ""):done() | |||
:tag("td"):addClass("templateSecondary"):wikitext(floorsArg or ""):done() | |||
rows | |||
:node(row) | |||
:allDone() | |||
end | end | ||
output | |||
:tag('table'):addClass("templateTheme"):cssText("text-align: center; margin: auto; width: 50%") | |||
:node(header) | |||
:node(rows) | |||
return tostring(output) | |||
end | end | ||
return p | return p |
Revision as of 09:31, 14 March 2024
--------------------------------------------------------------------------------
--
-- Module:Rescue Team DX Dungeon Fainted Pokémon table
--
--------------------------------------------------------------------------------
local p = {}
local mw = require('mw')
function p.main(frame)
local data = require("Module:Sandbox/test")
local metatable = {__index = function () return "" end}
setmetatable(data, metatable)
local args = frame.args
local output = mw.html.create()
local header = mw.html.create()
-- Header row
header
:tag('tr')
:tag('th'):addClass("templatePrimary"):attr("rowspan", "2" ):cssText("width: 10%"):wikitext("Sprite"):done()
:tag('th'):addClass("templatePrimary"):attr("colspan", "2" ):cssText("width: 10%"):wikitext("{{RescueTeamDX|Pokémon}}"):done()
:tag('th'):addClass("templatePrimary"):attr("colspan", "2" ):attr("rowspan", "2" ):cssText("width: 20%"):wikitext("{{RescueTeamDX|Types}}"):done()
:tag('th'):addClass("templatePrimary"):attr("rowspan", "2" ):cssText("width: 10%"):wikitext("{{RescueTeamDX|Level}}"):done()
:tag('th'):addClass("templatePrimary"):attr("rowspan", "2" ):cssText("width: 10%"):wikitext("Floors"):done()
:tag('td'):wikitext(recruit)
:tag('tr')
:tag('th'):addClass("templatePrimary"):cssText("width: 25%"):wikitext("English"):done()
:tag('th'):addClass("templatePrimary"):cssText("width: 25%"):wikitext("Japanese"):done()
-- Data rows
local rows = mw.html.create()
for i = 1, 150 do
local row = mw.html.create()
local monsterArg = args["pokemon_" .. i]
local floorsArg = args["floors_" .. i]
local levelArg = args["level_" .. i]
if not monsterArg and not floorsArg and not levelArg then
break -- exit loop when no more rows are found
end
local typeOne = data[monsterArg]["type1"] or ""
local typeTwo = data[monsterArg]["type2"] or ""
row
:tag("tr"):addClass("monstersTableRow"):done()
:tag("th"):addClass("templatePrimary"):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "50x50px"}}):done()
:tag("td"):addClass("templateSecondary"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}})
:tag("td"):addClass("templateSecondary"):wikitext(data[monsterArg]["ja"])
if typeTwo == nil or typeTwo == '' then
row
:tag('td'):addClass("templatePrimary"):attr("colspan", "2" ):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}}):done()
else
row
:tag('td'):addClass("templatePrimary"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}}):done()
:tag('td'):addClass("templatePrimary"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeTwo}}):done()
end
row
:tag("td"):addClass("templateSecondary"):wikitext(levelArg or ""):done()
:tag("td"):addClass("templateSecondary"):wikitext(floorsArg or ""):done()
rows
:node(row)
:allDone()
end
output
:tag('table'):addClass("templateTheme"):cssText("text-align: center; margin: auto; width: 50%")
:node(header)
:node(rows)
return tostring(output)
end
return p