Happy Early Access Launch! Please bear with us: We're doing our best to get the site updated. If we currently don't have what you're looking for, try checking our sister site, beastieball.info.
If you're looking to contribute to the site, we're happy to have you! Check out Beastiepedia:To Do List to see what needs done.
Find us in the Wishes Unlimited Discord in the "Beastiepedia: The Beastieball Wiki" thread in the Forums!
Module:Learners: Difference between revisions
From Beastiepedia: The Beastieball Wiki
No edit summary |
No edit summary |
||
Line 18: | Line 18: | ||
:tag("th"):wikitext("Beastie"):done() | :tag("th"):wikitext("Beastie"):done() | ||
if levels then | if levels then | ||
header:tag("th"):wikitext(" | header:tag("th"):wikitext("Level") | ||
end | end | ||
Line 25: | Line 25: | ||
tr:tag("td"):wikitext(result.Beastie) | tr:tag("td"):wikitext(result.Beastie) | ||
if levels then | if levels then | ||
tr:tag("td"):wikitext( | for rplay in mw.text.gsplit(result.Plays, ",", true) do | ||
local rplaysplit = mw.text.split(rplay, ";", true) | |||
if rplaysplit[1] == play then | |||
tr:tag("td"):wikitext(rplaysplit[2]) | |||
break | |||
end | |||
end | |||
end | end | ||
end | end |
Revision as of 16:03, 19 November 2024
Documentation for this module may be created at Module:Learners/doc
local p = {} local cargo = mw.ext.cargo local getArgs = require('Module:Arguments').getArgs function p.Main( frame ) local args = getArgs(frame) local play = args[1] or mw.title.getCurrentTitle().text local levels = args["level"] levels = levels and levels ~= "" local tables = (levels and "BeastieLearnset") or "BeastieLearnFriend" local fields = (levels and "Beastie,Plays") or "Beastie" local where = tables .. ".Plays HOLDS LIKE '" .. ((levels and play .. "%") or play) .. "'" local results = cargo.query(tables, fields, {where=where}) local tbl = mw.html.create('table'):addClass('wikitable') local header = tbl:tag("tr") :tag("th"):wikitext("Beastie"):done() if levels then header:tag("th"):wikitext("Level") end for _, result in ipairs(results) do local tr = tbl:tag("tr") tr:tag("td"):wikitext(result.Beastie) if levels then for rplay in mw.text.gsplit(result.Plays, ",", true) do local rplaysplit = mw.text.split(rplay, ";", true) if rplaysplit[1] == play then tr:tag("td"):wikitext(rplaysplit[2]) break end end end end return tbl end return p