famBags

120 - modified filter function

I change a function "famBags.Classification [FAMBAGSCRITERIA_REQUIREDLEVEL] = function (catindex, critindex)" in file "famBagsclassification.lua"

Here is the code:

local eval;
do
    local function dumb() return end
    
    local mem = setmetatable({}, {__mode = "v"});
    
    eval = function(s)
        if mem[s] then
            return mem[s];
        else
            local f = loadstring("return " .. (string.gsub(s, "%[lvl%]", UnitLevel("player"))));            
            if f then
                mem[s] = f;
                return f;
            else
                print("Unexpected value for required level: " .. s);
                mem[s] = dumb;
                return dumb;
            end
        end
    end
end

famBags.Classification[FAMBAGSCRITERIA_REQUIREDLEVEL] = function(catindex, critindex)
    local req = CURRENT_INFO.minLvl;
    if not req then return false end
    
    local crit = db[catindex].criterias[critindex];
    local value, operator = crit.value, crit.comparer;
    
    if not (value and operator) then return false end
    
    local min, max = eval(value)();
    
    if not min then return false end
    
    if operator == 1 then        -- Equal
        return req == min;
    elseif operator == 2 then    -- Greater or equal
        return req >= min;
    elseif operator == 3 then    -- Less or equal
        return req <= min;
    else                         -- Between
        return max and (min <= req and req <= max);
    end
end

when we write "[lvl]" in the inputbox, it is replaced by the character level

can be-type filters

Lesser than or equal: [lvl]
Greater than or equal: [lvl] + 1
Between: [lvl] - 10 [lvl]

This avoids having to change the filters every level up because the filter starts to automatically update

the problem is that at each update my amendment is clear

you could set up a similar function please :)

User When Change
poiuytreza5 Dec 03, 2012 at 13:03 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

Facts

Reported
Dec 03, 2012
Status
New - Issue has not had initial review yet.
Type
Task - Work item that doesn't change the code or docs
Priority
Medium - Normal priority.
Votes
0

Reported by

Possible assignees