Module:PlayerInfobox

local roblox_urls = require('Module:RobloxUrls') local links = require('Module:Links') local utils = require('Module:InfoboxUtils')

local function categorize(category) -- Categorize the page, but only if it is in the community namespace. -- See http://roblox.wikia.com/api.php?action=query&meta=siteinfo&siprop=namespaces for the number associated to each namespace. if mw.title.getCurrentTitle.namespace == 114 then return "" else return '' end end

local p = {}

function p._format_activity(args) local activity = args.activity:lower if activity == 'active' then return "Active" .. categorize("Active players") elseif activity == 'inactive' then return "Inactive" .. categorize("Inactive players") elseif activity == 'banned' then return "Banned" .. categorize("Banned players") elseif activity == "terminated" or activity == "permanently banned" or activity == "deleted" then return "Terminated" .. categorize("Terminated players") elseif activity == "deceased" then return "Deceased" .. categories("Deceased players") else return utils.error_message(" must be 'active', 'inactive', 'banned', 'terminated' or 'deceased'") end end

p.format_activity = utils.make_wrapper_function(p._format_activity)

function p._format_month_joined(args) local month, year = args['month joined']:match("(January)?(February)?(March)?(April)?(May)?(June)?(July)?(August)?(September)?(October)?(November)?(December)? (%d%d%d%d)") if month then return month .. ' ' .. year .. categorize(year .. " players") else return utils.error_message("invalid value for ; try something like \"October 2015\"") end end

p.format_month_joined = utils.make_wrapper_function(p._format_month_joined)

function p._format_membership(args) local membership = args.membership:lowercase

if membership == 'obc' or membership == 'outrageous builders club' or membership == 'outrageous builder\'s club' then return "Outrageous Builders Club" .. categorize("Category:Outrageous Builders Club players") elseif membership == 'tbc' or membership == 'turbo builders club' or membership == 'turbo builder\'s club' then return "Turbo Builders Club" .. categorize("Turbo Builders Club players") elseif membership == 'bc' or membership == 'builders club' or membership == 'builder\'s club' then return "Builders Club" .. categorize("Builders Club players") else return utils.error_message(" must be 'bc', 'tbc' or 'obc''") end end

p.format_membership = utils.make_wrapper_function(p._format_membership)

function p._format_place_visits(args) local language = mw.language.getContentLanguage -- This will work even if the number given is already formatted. local place_visits = language:parseFormattedNumber(args["place visits"]) if place_visits then -- Round the number of place visits and return it formatted. local power = 10^(#tostring(place_visits) - 1) power = power > 10000 and 10000 or power return language:formatNum(math.ceil(place_visits/power) * power) .. (place_visits > 750000 and categorize("Players with less than 750000 place visits") or '') else return utils.error_message("invalid number of place visits") end end

p.format_place_visits = utils.make_wrapper_function(p._format_place_visits)

return p