LoTROInterface

LoTROInterface (https://www.lotrointerface.com/forums/index.php)
-   Lua Programming Help (L) (https://www.lotrointerface.com/forums/forumdisplay.php?f=50)
-   -   using EffectList:Contains(effect)? (https://www.lotrointerface.com/forums/showthread.php?t=3745)

Grimmerthan 04-19-2019 07:39 PM

using EffectList:Contains(effect)?
 
Hi folks,

I want to improve DebuffVitals by reducing brute force searching down to a direct Contains() call. I strongly suspect this will improve performance issues, as well as being a more elegant solution.

However, I haven't yet figured out how to use the EffectList:Contains() method correctly, and I hope someone with more insight could share what they know?

I expect to pass a Turbine.Gameplay.Effect object, but I can't seem to create a Turbine.Gameplay.Effect object directly. Is there an enumeration of Effects that I can reference? Some list of asset tags that I could extract and then use (like various resource browsers have done)? Some constructor definition that uses specific unique IDs?

Can the method even be used this way, or am I barking up the wrong tree?

Thanks a lot,
Grimmerthan

Thurallor 04-19-2019 08:19 PM

Interesting idea. I didn't notice that function, back when I was trying to get target effects to work.

I don't think you can create the objects directly; nor is there any enumeration of all possible effects. I think the best you can do is save all of the effects into a hash as you receive them from EffectAdded events or EffectList:Get(). Of course, if you are maintaining that hash, there's no reason to call the Contains() function. Just do a direct hash table lookup.

In case it's not clear, I mean maintaining a list of the form

Code:

{
  [effectObject1] -> true,
  [effectObject2] -> true,
  [effectObject3] -> true
  ...
}

so you can use Lua's built-in hash function to see if an effectObject is present in the list.

I still have my fingers crossed that the situation will be improved in U24.

Grimmerthan 04-19-2019 11:26 PM

Hmm, I'm not sure about what you've described. It doesn't fit into the usage patterns and code flow, or I don't understand what you meant, or both, or something else.

I have a different idea, which is to persist the first one of a specific effect, and then use it for all subsequent checks. I don't know if an Effect from one EffectList can be used to check against a different EffectList though. Need to do some more testing.

Fall-back plan though. I have hopes that a dev may respond on Lotro forums.

Thurallor 04-20-2019 10:49 AM

Well, I'm not quite sure how you want to use EffectList:Contains(), but my point is that
if (effectList:Contains(effect)) then
is probably not significantly more efficient than
if (effectIsPresent[effect]) then
where effectIsPresent is a hash table that you have built with
effectList.EffectAdded = function(obj, args)
local effect = obj:Get(args.Index);
effectIsPresent[effect] = true;
end
effectList.EffectRemoved = function(obj, args)
local effect = obj:Get(args.Index);
effectIsPresent[effect] = false;
end

of course assuming that the "EffectRemoved" event is fixed in U24.

Note: I believe each instance of an effect has its own distinct object. So you can't create an Effect object for a given effect and use that for comparison to future instances of that effect.

Grimmerthan 04-22-2019 11:26 PM

Taking it up a level, I want to reduce impact of the plugin on game performance. I've had feedback about lag from users. I'm pretty sure it's coming from the repeated Effect* callbacks feeding into nested for loops.

I hoped that I could use EffectList:Contains() to cut down on the loop. Instead, I'm going to do some adjustable throttling instead, to cut down on callback triggers. Maybe some additional handling cases where there are multiple DV windows targeted on one thing.


All times are GMT -5. The time now is 10:44 AM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI