Documentation for this module may be created at Module:Infobox item/doc
-- Joritochip
-- Helper functions for item infobox
local utils = require("Module:Utils")
local currency = require("Module:Currency")
local categorization = require("Module:Categorization")
local categorize = categorization.categorize_in_namespaces(0)
local p = {}
function p._format_availability(args)
local available = string.lower(args.available)
return args.available .. (available == "permanent" and categorize("Permanent items") or "")
end
p.format_availability = utils.make_wrapper_function(p._format_availability)
function p._format_item_type(args)
local item_type = string.lower(args.type)
if item_type == "accessory" or item_type == "accessories" then
return "[[Accessory]]" .. categorize("Accessories")
elseif item_type == "skirt" or item_type == "skirts" then
return "[[Skirt]]" .. categorize("Skirts")
elseif item_type == "shoes" or item_type == "shoe" then
return "[[Shoes]]" .. categorize("Shoes")
else
error("Valid \"type\" parameters are: accessory, skirt, shoes")
end
end
p.format_item_type = utils.make_wrapper_function(p._format_item_type)
function p._format_customizable(args)
local customize = string.lower(args.customize)
if customize == "yes" or customize == "true" then
return "Yes" .. categorize("Items that can be customized")
elseif customize == "no" or customize == "false" then
return "No" .. categorize("Items that cannot be customized")
elseif customize == "patterns" or customize == "pattern" then
return "Patterns only" .. categorize("Items that can only be customized with patterns")
else
error("Valid \"customize\" parameters are: yes, no, patterns")
end
end
p.format_customizable = utils.make_wrapper_function(p._format_customizable)
function p._format_tradable(args)
local trade = utils.validate_boolean(args.trade)
if trade == true then
return "Yes" .. categorize("Items that can be traded")
elseif trade == false then
return "No" .. categorize("Items that cannot be traded")
else
error("Valid \"trade\" parameters are: yes, no")
end
end
p.format_tradable = utils.make_wrapper_function(p._format_tradable)
function p._format_toggles(args)
local toggles = utils.validate_boolean(args.toggles)
if toggles == true then
return "Yes" .. categorize("Items with toggles")
elseif toggles == false then
return "No"
else
error("Valid \"toggles\" parameters are: yes, no")
end
end
p.format_toggles = utils.make_wrapper_function(p._format_toggles)
function p._format_stackable(args)
local stackable = utils.validate_boolean(args.stackable)
if stackable == true then
return "Yes" .. categorize("Items that are stackable")
elseif stackable == false then
return "No"
else
error("Valid \"stackable\" parameters are: yes, no")
end
end
p.format_stackable = utils.make_wrapper_function(p._format_stackable)
function p._format_description(args)
local description = args.description
if string.len(description) >= 270 then
return "<div class=\"mw-collapsible mw-collapsed\"><div class=\"mw-collapsible-content\">" .. description .. "</div></div>"
else
return description
end
end
p.format_description = utils.make_wrapper_function(p._format_description)
return p