Module:Eicons

local function plural(str, postfix) if postfix == '' then return str end if postfix == 's' or postfix == 'es' then return str .. postfix end if postfix == 'ies' then return str:sub(0, -2) .. postfix end return str end

local function parameter(parameter, base) if parameter == 'y' or parameter == 'yes' then return true end if parameter == 'n' or parameter == 'no' then return false end return base end

local function getVersionInfo(raw) local vd,vc,vo,vm,v3,vj vd = raw:find('d') vc = raw:find('c') vo = raw:find('o') vm = raw:find('m') v3 = raw:find('3') vj = raw:find('j') return vd,vc,vo,vm,v3,vj end

local function eicons(text, vd, vc, vo, vm, v3, vj, _small, _before, frame) local result='' if vd or vc or vo or vm or v3 or vj then if text ~= '' then result = result .. ' '		else result = result .. _before end local space = false if vd then space = true result = result .. frame:expandTemplate{ title = 'icon/desktop', args = {small = _small } } end if vc then if space then result = result .. '&thinsp;' end space = true result = result .. frame:expandTemplate{ title = 'icon/console', args = {small = _small } } end if vj then if space then result = result .. '&thinsp;' end space = true result = result .. frame:expandTemplate{ title = 'icon/japan', args = {small = _small } } end if vo then if space then result = result .. '&thinsp;' end space = true result = result .. frame:expandTemplate{ title = 'icon/oldgen', args = {small = _small } }

end if v3 then if space then result = result .. '&thinsp;' end result = result .. frame:expandTemplate{ title = 'icon/3ds', args = {small = _small } } end end return result end

-- main return object return { go = function(frame) local _arg1 = frame.args[1]:match("^%s*(.-)%s*$") local _arg2 = frame.args[2]:match("^%s*(.-)%s*$") local _versions = frame.args['v']:match("^%s*(.-)%s*$") local _t = frame.args['t']:match("^%s*(.-)%s*$") local _desktop = frame.args['desktop']:match("^%s*(.-)%s*$") local _console = frame.args['console']:match("^%s*(.-)%s*$") local _oldgen = frame.args['old-gen']:match("^%s*(.-)%s*$") local _mobile = frame.args['mobile']:match("^%s*(.-)%s*$") local _3ds = frame.args['3ds']:match("^%s*(.-)%s*$") local _japan = frame.args['japan']:match("^%s*(.-)%s*$") local _invert = frame.args['invert']:match("^%s*(.-)%s*$") local _small = frame.args['small']:match("^%s*(.-)%s*$") local _before = frame.args['before']:match("^%s*(.-)%s*$")

local vd,vc,vo,vm,v3,vj = getVersionInfo(_versions)

if _invert ~= '' then vd = not vd		vc = not vc		vo = not vo		vm = not vm		v3 = not v3		vj = false end

if vd and vc and vo and vm and v3 then vd = false vc = false vo = false vm = false v3 = false vj = false end

vd = parameter(_desktop, vd) vc = parameter(_console, vc) vo = parameter(_oldgen, vo) vm = parameter(_mobile, vm) v3 = parameter(_3ds, v3) vj = parameter(_japan, vj)

local text = _t if text ==  and _arg2 ~=  then text = plural(_arg1, _arg2) end

local result = text .. eicons(text, vd, vc, vo, vm, v3, vj, _small, _before, frame)

return result end, icons = function(versions, _small, frame) local vd,vc,vo,vm,v3,vj = getVersionInfo(versions) if vd and vc and vo and vm and v3 then vd = false vc = false vo = false vm = false v3 = false vj = false end return eicons(, vd, vc, vo, vm, v3, vj, _small, , frame) end }