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 14: Line 14:
     local results = cargo.query(tables, fields, {where=where})
     local results = cargo.query(tables, fields, {where=where})
     local bigHeaderText = (levels and "From Level Up") or "With Friendship"
     local bigHeaderText = (levels and "From Level Up") or "With Friendship"
    tbl:tag("tr"):tag("th"):attr("colspan", (level and 2) or 1):wikitext(bigHeaderText)


     local tbl = mw.html.create('table'):addClass('wikitable')
     local tbl = mw.html.create('table'):addClass('wikitable')

Revision as of 16:56, 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] ~= ""  and 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 bigHeaderText = (levels and "From Level Up") or "With Friendship"
    tbl:tag("tr"):tag("th"):attr("colspan", (level and 2) or 1):wikitext(bigHeaderText)

    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("[[File:" .. result.Beastie .. "Idle.png|80x80px]]" .. " " .. 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