PDA

View Full Version : 'Buff Removed' How to Identify..


Daorven
04-21-2019, 05:22 PM
Hi,

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 (https://www.lotro.com/forums/showthread.php?428196-Writing-LoTRO-Lua-Plugins-for-Noobs&p=5784203#post5784203)




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 == nil then

[I](some code to create and save your own custom control to show effect)
end


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


end
-------------------------------------------------------------------------------------------------


-------------------------------------------------------------------------------------------------
-- 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 then

[I](some code to remove your own custom control saved in a table)
end


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


end
-------------------------------------------------------------------------------------------------


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

OliviaLorelei
01-15-2024, 02:35 PM
Which programming language is above? Looks like py but the commenting takes me out.

Garan
01-15-2024, 03:43 PM
Which programming language is above? Looks like py but the commenting takes me out.

It is Lua. LotRO plugins are written in Lua. For language reference, see:
https://www.lua.org/manual/5.1/