LoTROInterface (https://www.lotrointerface.com/forums/index.php)
-   Tutorials & Other Helpful Information (L) (https://www.lotrointerface.com/forums/forumdisplay.php?f=21)
-   -   'Buff Removed' How to Identify.. (https://www.lotrointerface.com/forums/showthread.php?t=3746)

Daorven 04-21-2019 05:22 PM

'Buff Removed' How to Identify..

To identify Effect removed (buff/debuff) , we can get the ID with GetID() function in event "EffectRemoved", dont need to search in a saved table. If this can help, have a nice day.

-- callback function (see link )
GARAN Event handling Tutorial


import "Turbine";
import "Turbine.Gameplay";

-- callback function
(click link above to get tutorial from GARAN)

-- get unit player
local up = Turbine.Gameplay.LocalPlayer:GetInstance();
-- get effects
local ue = up:GetEffects(); 
-- create table to save effect control
local saved_effect = {};

-- event effect added
local effectAdded = function(sender, args)
        -- get effect added to unit player
        local effect = ue:Get(args.Index);

      -- save new effect control to table
        -- we get a unique id for each new effect, new id for same effect is possible

        local id = effect:GetID();                               
        if saved_effect[id] == nil then
                        (some code to create and save your own custom control to show effect)

        -- debug
        Turbine.Shell.WriteLine("NEW buff name: "..tostring(effect:GetName()));  -- localized effect name
        Turbine.Shell.WriteLine("GetID(): "..tostring(effect:GetID()));  -- unique ID for this new effect added


-- event effect removed
local effectRemoved = function(sender, args)
      -- we get the unique id for effect removed
        local id = args.Effect:GetID();       
        -- after we can directly access to the control saved in 'saved_effect' (the index is the id get with GetID() function)
        if saved_effect[id] then
                        (some code to remove your own custom control saved in a table)

        -- debug       
        Turbine.Shell.WriteLine("REMOVED buff name "..tostring(args.Effect:GetName()));  -- localized effect name
        Turbine.Shell.WriteLine("buff removed ID :"..tostring(args.Effect:GetID()));  -- unique ID for this effect removed


-- event declaration
AddCallback(ue, "EffectAdded", effectAdded);-- effect added
AddCallback(ue, "EffectRemoved", effectRemoved);-- effect removed

All times are GMT -5. The time now is 11:31 AM.

vBulletin® - Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.