FANDOM


local categorization = require('Module:Categorization')
local links = require('Module:Links')
local utils = require('Module:Utils')
local roblox_urls = require('Module:RobloxUrls')
 
local categorize = categorization.categorize_in_namespaces('Catalog', 'Community')
 
return {
    error_message = function(...)
        return error(...)
    end;
 
    player_link = function(player, id)
        if player:lower() == 'none' or player:lower() == 'no owner' or player:lower() == 'nobody' then
            return "None"
        else
            -- This uses pcall to call mw.title.makeTitle in case the expensive parser function limit is exceeded.
            local status_code, player_page = pcall(mw.title.makeTitle, 'Community', player)
            if status_code and player_page and player_page.exists then
                -- If the player has a page on this wiki, link to it. Otherwise, link to the Roblox profile.
                return links.wikilink(player_page, player)
            elseif id then
                return links.external_link(roblox_urls.user_from_id(id), player)
            else
                return links.external_link(roblox_urls.user_from_username(player), player)
            end
        end
    end;
 
    format_number = function(
            number, max_round, category, category_min, filter_flag)
        number = utils.parse_number(number, true) -- Guaranteed to return a number or error
        if max_round then
            -- Round the number.
            local power = 10^(#tostring(number) - 1)
            power = power > max_round and max_round or power
            number = math.ceil(number/power) * power
        end
        local formatted_number = utils.format_number(number)
        if category then
            if category_min then
                if number < category_min then
                    if filter_flag then
                        filter_flag = tostring(mw.html.create("span")
                            :wikitext("FLAG::" .. filter_flag)
                            :css("display", "none")
                        )
                    end
                    return formatted_number .. categorize(category) .. (filter_flag or '')
                else
                    return formatted_number
                end
            else
                return formatted_number .. categorize(category)
            end
        else
            return formatted_number
        end
    end;
}
Community content is available under CC-BY-SA unless otherwise noted.