lotrointerface.com
Search Downloads

LoTROInterface SVN SequenceBars

[/] [trunk/] [Thurallor/] [Common/] [Utils/] [New.lua] - Rev 121

Go to most recent revision | Compare with Previous | Blame | View Log

-- New functions that supersede the ones in Utils.lua.
-- Needs to be in a separate file in case someone installs one of my plugins that contains an old copy of Utils.lua.

-- Missing/outdated enumeration values
Turbine.Gameplay.Attributes.MinstrelStance.Harmony = nil;
Turbine.Gameplay.Attributes.MinstrelStance.Warspeech = nil;
Turbine.Gameplay.Attributes.MinstrelStance.Melody = 0;
Turbine.Gameplay.Attributes.MinstrelStance.Dissonance = 1;
Turbine.Gameplay.Attributes.MinstrelStance.Resonance = 2;
Turbine.Gameplay.Attributes.MinstrelStance.None = 3;

-- New versions of RemoveCallback() and DoCallbacks() that tolerate removing an event handler from within an event handler:
function _G.RemoveCallback(object, event, callback)
    if (callback == nil) then
        return;
    end
    local handlers = object[event];
    if (handlers == callback) then
        object[event] = nil;
    elseif (type(handlers) == "table") then
        local f, i;
        repeat
            i, f = next(handlers, i);
            if (f == callback) then
                handlers[i] = nil;
            end
        until (i == nil);
        if (next(handlers) == nil) then
            object[event] = nil;
        end
    end
end

function _G.DoCallbacks(object, event, args)
    local handlers = object[event];
    if (type(handlers) == "function") then
        handlers(object, args);
    elseif (type(handlers) == "table") then
        if (next(handlers) == nil) then
            -- If all handlers have been removed, remove the table.
            object[event] = nil;
        else
            local f, i;
            repeat
                i, f = next(handlers, i);
                if (type(f) == "function") then
                    f(object, args);
                end
            until (i == nil);
        end
    end
end

Go to most recent revision | Compare with Previous | Blame


All times are GMT -5. The time now is 01:22 AM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui