Module:LimitedCropAutobox

local Crops = require('Module:Utilities').LimitedCrops 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 Crops[frame.args.Name] then return '' end local RealPage = Namespace == '' and Crops[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 Crops[frame.args.Name].OriginalCost), Quantity = (RealPage and Crops[frame.args.Name].Quantity), Worth = (RealPage and Crops[frame.args.Name].Worth), VIP = (RealPage and Crops[frame.args.Name].VIP), Stages = (RealPage and Crops[frame.args.Name].Stages) }   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 Crops[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 if Info.Quantity and tonumber(Info.Quantity) then Add(([===[ ]===]):format(commas(Info.BaseCost))) end if Info.Worth and tonumber(Info.Worth) then Add(([===[ ]===]):format(commas(Info.Worth))) end if Info.VIP and tonumber(Info.VIP) then Add(([===[ ]===]):format(commas(Info.VIP))) end if Info.Stages and tonumber(Info.Stages) then Add(([===[ ]===]):format(commas(Info.Stages))) end done return RealPage and  or , Infobox end return p