FANDOM


-- Any major change to the infobox templates or new parameter should be suggested on the talk page first.
local categorization = require('Module:Categorization')
local yesno = require('Dev:Yesno')
local roblox_urls = require('Module:RobloxUrls')
local links = require('Module:Links')
local currency = require('Module:Currency')
local utils = require("Module:Utils")
local infobox_utils = require('Module:InfoboxUtils')
local enumerate_genres = require('Module:Genre')._enumerate_genres
local article = require('Module:Article')
local staffData = require('Module:RobloxStaff')
 
local categorize = categorization.categorize_in_namespaces(0, 'Catalog', 'Community')
 
local p = {}
 
function p._format_title(args)
    if args.id == '{{{id}}}' or args.id == nil then
        return infobox_utils.error_message("<code>id</code> parameter missing and is required")
    elseif args.id == "unknown" then
        return args.name .. categorize("Items with unknown identifier")
    elseif tonumber(args.id) then
        if tonumber(args.id) < 0 then
            return infobox_utils.error_message("<code>id</code> cannot be negative")
        else
            if yesno(args["bundle"]) then
                return links.external_link(roblox_urls.bundle_from_id(args.id), args.name)
            else
                return links.external_link(roblox_urls.item_from_id(args.id), args.name)
            end
        end
    else
        return infobox_utils.error_message("<code>id</code> must be a number")
    end
end
 
p.format_title = utils.make_wrapper_function(p._format_title, true)
 
function p._format_13plus(args)
    if yesno(args['13plus']) then
        return "[[File:13plus.png|link=|alt=This item was formerly for users 13 years old or older.]]" .. categorize("Former 13+ items")
    end
end
 
p.format_13plus = utils.make_wrapper_function(p._format_13plus)
 
function p._format_tickets(args)
    if tonumber(args.tickets) then
        return "Formerly&nbsp;" .. currency._format_tickets {amount = args.tickets} .. categorize("Items formerly available for tickets")
    else
        return infobox_utils.error_message("<code>tickets</code> must be a number")
    end
end
 
p.format_tickets = utils.make_wrapper_function(p._format_tickets)
 
function p._format_robux(args)
    if yesno(args.limitedu) or yesno(args.limited) then
        return "Formerly&nbsp;" .. currency._format_robux {amount = args.robux}
    elseif yesno(args.sale) or yesno(args.buyableforsale) then
        return "Sale price: " .. currency._format_robux {amount=args.robux}
    else
        -- User:Joritochip
        -- This is a little messy, I will attempt to clean it up later
        local toReturn = currency._format_robux {amount=args.robux}
        if args.premiumRobux then
            local premiumPrice = currency._format_robux {amount=args.premiumRobux}
            toReturn = toReturn .. "<div style=\"margin-left:5px;margin-top:2px\"><span style=\"margin-right:1px\">(</span>" .. premiumPrice .. "<span style=\"margin-left:5px\">with [[Roblox Premium]])</span></div>" .. categorize("Items with discounted Roblox Premium price")
        end
        return toReturn
    end
end
 
p.format_robux = utils.make_wrapper_function(p._format_robux)
 
function p._format_free(args)
    if yesno(args.free) then
        return currency._format_free() .. categorize("Free items")
    end
end
 
p.format_free = utils.make_wrapper_function(p._format_free)
 
function p._format_creator(args)
    local creator = args.creator or args.owner
    if creator:lower() ~= "roblox" then
        local data = staffData.getRole(creator)
        if not mw.title.getCurrentTitle():inNamespaces("Catalog") then
            return infobox_utils.player_link(creator)
        else
            return infobox_utils.player_link(creator) .. categorize((data[1] == "Admin" or data[1] == "Former_Admin") and "Unofficial items" or "UGC items")
        end
    end
end
 
p.format_creator = utils.make_wrapper_function(p._format_creator)
 
function p._format_genres(args)
    if args.genres == 'none' then
        return ''
    else
        return enumerate_genres {genres = args.genres, ["category suffix"] = args["category suffix"] or "items"}
    end
end
 
p.format_genres = utils.make_wrapper_function(p._format_genres)
 
function p._format_membership(args)
    local membership = args.membership and args.membership:lower()
    if membership then
        if membership == "obc" or membership == "outrageous builders club" or membership == "outrageous builder's club" then
            return "[[Outrageous Builders Club]]" .. categorize("Former Outrageous Builders Club items")
        elseif membership == "tbc" or membership == "turbo builders club" or membership == "turbo builder's club" then
            return "[[Turbo Builders Club]]" .. categorize("Former Turbo Builders Club items")
        elseif membership == "bc" or membership == "builders club" or membership == "builder's club" then
            return "[[Builders Club]]" .. categorize("Former Builders Club items")
        elseif membership == "premium" or membership == "p" or membership == "Roblox Premium" then
            return "[[Roblox Premium]]" .. categorize("Roblox Premium items")
        else
            return infobox_utils.error_message("<code>membership</code> must be 'bc', 'tbc', 'obc', or 'premium'")
        end
    end
end
 
p.format_membership = utils.make_wrapper_function(p._format_membership)
 
function p._categorize_by_limited_status(args)
    if yesno(args.limitedu) then
        return categorize("Limited unique items")
    elseif yesno(args.limited) then
        return categorize("Limited items")
    end
end
 
p.categorize_by_limited_status = utils.make_wrapper_function(p._categorize_by_limited_status)
 
return p
Community content is available under CC-BY-SA unless otherwise noted.