Roblox Wiki
Advertisement
Roblox Wiki


local categorization = require('Module:Categorization')
local utils = require('Module:Utils')
local yesno = require('Dev:Yesno')

local categorize = categorization.categorize_in_namespaces(0, 'Community')

local p = {}

local genres = {'Building', 'Horror', 'Town and City', 'Military', 'Comedy', 'Medieval', 'Adventure', 'Sci-Fi', 'Naval', 'FPS', 'RPG', 'Sports', 'Fighting', 'Western'}

function p._format_genre(args)
    local genre_name = args.genre
    local genre_string = genre_name:lower() -- Use the lowercase string for comparisons.
    if genre_string == 'all' then
        return "All"
    else
        for _, genre in next, genres do
            if genre:lower() == genre_string then
                return genre .. (args["category suffix"] and (categorize(genre .. " " .. args["category suffix"])) or "")
            end
        end
        -- If the function didn't return in the loop, the genre string corresponded to none of the recognized genres.
        return error("'" .. genre_string .. "' is not a valid genre.")
    end
end

p.format_genre = utils.make_wrapper_function(p._format_genre)


return p
Advertisement