modified filter function #120


  • New
  • Task
Open
Assigned to _ForgeUser455745
  • _ForgeUser4455323 created this issue Dec 3, 2012

    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 :)

  • _ForgeUser4455323 added the tags New Task Dec 3, 2012

To post a comment, please login or register a new account.