Module:InfoboxUtils

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

local categorize = utils.categorize(0)

return { error_message = function(...) return error(...) end;

player_link = function(player, id) local player_page = mw.title.makeTitle(0, player) -- If the player has a page on this wiki, link to it. Otherwise, link to the ROBLOX profile. if player:lower == 'none' or player:lower == 'no owner' or player:lower == 'nobody' then return "None" elseif player_page.exists then 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;

format_number = function(number, max_round, category, category_min) 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 return formatted_number .. categorize(category) else return formatted_number end else return formatted_number .. categorize(category) end else return formatted_number end end; }