LoTROInterface - View Single Post - 'Buff Removed' How to Identify..
View Single Post
Unread 04-21-2019, 05:22 PM
Daorven Daorven is offline
The Wary
Join Date: Apr 2019
Posts: 4
'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

Last edited by Daorven : 04-22-2019 at 06:51 AM.
Reply With Quote