Module:DecorAutobox

local Decors = require('Module:Utilities').Decor local p = {} local function commas(str) str = tostring(str) return #str % 3 == 0 and str:reverse:gsub("(%d%d%d)", "%1,"):reverse:sub(2) or str:reverse:gsub("(%d%d%d)", "%1,"):reverse end function p.CreateInfobox(frame) local Namespace = frame:preprocess('') if not Namespace then return '' end frame.args.Name = frame.args.Name and mw.text.decode(frame.args.Name) if Namespace == '' and not Decors[frame.args.Name] then return '' end local RealPage = Namespace == '' and Decors[frame.args.Name] and true or false local Info = { title = (RealPage and frame.args.Name) or frame.args.title1 or frame.args.title or frame:preprocess(''), image1 = frame.args.image1 or ('%s.png'):format(frame.args.Name), caption1 = frame.args.caption1, BaseCost = (RealPage and Decors[frame.args.Name].Cost), }   for i,v in pairs(Info) do        pcall(function            Info[i] = tonumber(tostring(string.gsub(v, ',', ''))) or Info[i]        end) if v ==  or v == ' ' or string.match(tostring(v), ']+)') then Info[i] = nil end   end    Info.image1 = Info.image1 or ('%s.png'):format(frame.args.Name)    Info.caption1 = Info.caption1 or (RealPage and Decors[frame.args.Name].Description)    local Infobox = (' '):format(mw.uri.encode(Info.title, 'WIKI'))    local function Add(str)            Infobox = ('%s%s'):format(Infobox, str)    end    local function done        Infobox = ('%s '):format(Infobox)        Infobox = frame:preprocess(Infobox)    end    Add((                %s             ):format(Info.title or 'Missing Title'))    Info.caption1 = (Info.image1 and (Info.caption1 or )) or 'Image currently unavailable'    if Info.image1 then        Add((                         %s                    %s                ):format(Info.caption1 or '', Info.image1 or Info.image2 or ))    end    if Info.BaseCost and tonumber(Info.BaseCost) then Add(([===[ ]===]):format(commas(Info.BaseCost))) end done return RealPage and  or , Infobox end return p