Documentation for this module may be created at Module:Beast Signer Beasts/doc

-- <nowiki>
--------------------------------------------------------------------------------
-- This module provides tools for covering beasts in Beast Signer.
--------------------------------------------------------------------------------
local p = {}
local getArgs = require("Dev:Arguments").getArgs
local userError = require("Dev:User error")
local data = mw.loadData("Module:Beast Signer Beasts/data")

--------------------------------------------------------------------------------
-- Generates a navigational gallery for linking to multiple beasts.
--------------------------------------------------------------------------------
function p.navgallery(frame)
    local args = getArgs(frame)
    local link = "%s|link=%s|%s (%s)\n"
    local gallery = mw.html.create("gallery")
        :attr("hideaddbutton", "true")
        :attr("navigation", "true")

    for _, name in ipairs(args) do
        local beast = data[name]

        if not beast then
            return userError("the beast <code>" .. name .. "</code> does not exist")
        end

        local tmp

        if beast.stage == 0 then
            tmp = "Egg"
        elseif beast.stage == 1 then
            tmp = "Stage 1"
        else
            tmp = "Stage " .. beast.stage .. " " .. beast.form .. " form"
        end

        gallery:wikitext(link:format(
            beast.image,
            beast.article,
            beast.link,
            tmp
        ))
    end

    return frame:preprocess(tostring(gallery))
end

return p

-- </nowiki>
-- [[Category:Lua Modules]]
Community content is available under CC-BY-SA unless otherwise noted.