Quantcast That pesky EntityControl! May I please get some guidance? - LoTROInterface
VGInterface.com
Search Downloads


Go Back   LoTROInterface > LotRO > Developer Discussions > Lua Programming Help (L)

Reply
Thread Tools Display Modes
  #1  
Unread 06-14-2018, 03:20 PM
Grimmerthan Grimmerthan is offline
The Undefeated
Interface Author - Click to view interfaces
 
Join Date: Aug 2014
Posts: 8
That pesky EntityControl! May I please get some guidance?

Hi folks,

I'm working on a plugin to help monitor boss debuffs (like frost/fire-lore). I'm basing it off a re-build of the m_vitals plugin, a plugin which I think is pretty awesome. The plugin is intended to create multiple target trackers, with each tracker observing morale/power, corruptions, and specific debuffs.

The issue I'm hitting is that the last EntityControl for tracking targets no longer connects to what should be its target, when my LocalUser changes targets. For example, when I create 4 trackers, the first 3 work correctly, and the 4th does not.

I've tried multiple ways of structuring code (and broken things horribly several times!), based on other plugins and Lua guides, and the problem persists across all of them. I feel like there's a basic concept or syntax that I'm missing.

May I please get some guidance or advice or correction? The code is at
https://github.com/grimmerthan/DebuffVitals

At this time, a good chunk of the code is commented out, with enough left in to demonstrate the issue. Also, I haven't done much programming or scripting in the last few years other than some ugly python scripts, so please be kind

Thanks in advance
Grimmerthan
Reply With Quote
  #2  
Unread 06-14-2018, 05:01 PM
Garan's Avatar
Garan Garan is online now
The Undying
Interface Author - Click to view interfaces
 
Join Date: Oct 2010
Posts: 245
It's been a long time since I played with targets, but as I recall the implementation of Lua targets is intended to only track the current target of an Actor. If the Actor changes targets then the targetChanged event fires for that Actor and all references to the prior target become nil and eventually get garbage collected. You are supposed to implement an event handler for the targetChanged event and update your control to the new target. So, the target control is meant to track the current target of a player or mob, not stay on a specific actor. There may be a number of reasons why the devs implemented it this way but I suspect it was simply the easiest way to hook into the underlying targeting mechanism - basically the same thing raid target assists do (they probably piggy-back off that same code).

So, for your plugin to work, you would need distinct actors staying targeted on the mobs you are interested in tracking and not changing targets. I suspect that would not be desirable for your plugin.

It seems you are trying to create trackers that work much like the windows the game creates when you press "H" - a small window that stays targeted on the item or mob you have target at that moment. I wish the Lua implementation worked that way, it would have been far more useful

Last edited by Garan : 06-14-2018 at 05:06 PM.
Reply With Quote
  #3  
Unread 06-14-2018, 05:38 PM
Grimmerthan Grimmerthan is offline
The Undefeated
Interface Author - Click to view interfaces
 
Join Date: Aug 2014
Posts: 8
Thanks Garan for your comments. I think this fits with what I'm seeing. It seems that only the last created EntityControl maintains the connection to LocalUser.

The guy who did m_vitals was able to make that plugin work the way that I'd like to see. I will dig back into his code and see if I can figure it out. Worse comes to worse, maybe I could embed a 2nd EntityControl to shield the first.
Reply With Quote
  #4  
Unread 06-14-2018, 11:30 PM
Grimmerthan Grimmerthan is offline
The Undefeated
Interface Author - Click to view interfaces
 
Join Date: Aug 2014
Posts: 8
Ok, I isolated the behaviour and stripped it down to one line of code.

The EntityControl will maintain a target as expected, if :GetTarget() is called again, prior to LocalPlayer changing target.

The EntityControl loses the connection to the target the next time LocalPlayer changes target, with this call order:
Code:
        local Target = LocalUser:GetTarget()
        self.TargetSelection:SetEntity( Target )
It will maintain a connection, when this is done:
Code:
        self.TargetSelection:SetEntity( LocalUser:GetTarget() )
        local Target = LocalUser:GetTarget()
Neat

Last edited by Grimmerthan : 06-15-2018 at 09:13 AM.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:24 PM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | VGInterface | LoTROInterface | MMOInterface | Swtorui