Module:ItemInfobox

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 categorize = utils.categorize('Catalog', 'Community')

local p = {}

function p._format_title(args) if args.id == '' then return infobox_utils.error_message(" parameter missing and is required.") elseif tonumber(args.id) then if args.id == "0" then return categorize("Items which are not in the catalog") else return links.plain_external_link(roblox_urls.item_from_id(args.id), args.name) end else return infobox_utils.error_message(" must be a number") end end

p.format_title = utils.make_wrapper_function(p._format_title)

function p._format_13plus(args) if yesno(args['13plus']) then return "" .. categorize("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 " .. currency._format_tickets {amount = args.tickets} else return infobox_utils.error_message(" must be a number") end end

p.format_tickets = utils.make_wrapper_function(p._format_tickets)

function p._format_robux(args) local formerly = yesno(args.limited) or yesno(args.limitedu) if tonumber(args.robux) then return (formerly and "Formerly " or "") .. currency._format_robux {amount = args.robux} else return infobox_utils.error_message(" must be a number") end end

p.format_robux = utils.make_wrapper_function(p._format_robux)

function p._format_free(args) if yesno(args.free) then return "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 if args.categorize == 'no' then return infobox_utils.player_link(creator) else return infobox_utils.player_link(creator) .. categorize("Unofficial items") end end end

p.format_creator = utils.make_wrapper_function(p._format_creator)

function p._format_genres(args) return enumerate_genres {genres = args.genres, ["category suffix"] = args["category suffix"] or "items"} 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("Outrageous Builders Club items") elseif membership == "tbc" or membership == "turbo builders club" or membership == "turbo builder's club" then return "Turbo Builders Club" .. categorize("Turbo Builders Club items") elseif membership == "bc" or membership == "builders club" or membership == "builder's club" then return "Builders Club" .. categorize("Builders Club items") else return infobox_utils.error_message(" must be 'bc', 'tbc' or 'obc'") 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