Thread Tools Display Modes
04/09/18, 12:13 AM   #1
manavortex
 
manavortex's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 138
[outdated] ZO_InteractionManager:GetChattererName()

Hey Chip,
I'm currently hooking up DailyAutoshare to work like Dolgubon's Lazy Writ Crafter and automatically accept/turn in quests. By doing so I found that there's no way to get the name of the NPC I'm chattering with - instead, I have to gather the string for every Quest I want to turn in so I can check if the right dialogue option is displayed.
Could you please expose the name of the NPC via API?

 
04/09/18, 04:03 AM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,566
Did you try GetUnitName("interact")? I use that to get the name of trader NPCs while chatting with them and it works just fine.
 
04/09/18, 04:05 AM   #3
manavortex
 
manavortex's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 138
mind = blown.
If that works, I have a lot less strings to parse.
 
04/13/18, 02:12 PM   #4
eventHandler
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 12
Originally Posted by manavortex View Post
mind = blown.
If that works, I have a lot less strings to parse.
ZO_InteractWindowTargetAreaTitle:GetText()
 
04/13/18, 07:00 PM   #5
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 408
Originally Posted by eventHandler View Post
ZO_InteractWindowTargetAreaTitle:GetText()
That's what I use, but I would still suggest getunitname. The interact window method requires adding - to either side (or taking them out)
 
04/16/18, 06:09 AM   #6
eventHandler
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 12
Originally Posted by Dolgubon View Post
That's what I use, but I would still suggest getunitname. The interact window method requires adding - to either side (or taking them out)
I'm not sure I follow your second sentence.

:GetText() returns a new copy of the text, it doesn't remove the text from the source or give you a "pointer" to the current text (to be able to modify it directly). That's why you still have to use :SetText() to change the contents.

The reason I wouldn't use GetUnitName(), is because it's so specific and not re-usable; it doesn't provide any insight into how to find other information through trial and error. Whereas :GetText() works for a lot of different classes, and provides subtle insight into the lua language concepts.

Actually, you meant the dash character; I thought you were separating a thought. My addon removes those, so I wasn't thinking about them.

name = string.gsub(ZO_InteractWindowTargetAreaTitle:GetText(), '[^%w\' ]', '') would almost work, if not for Razum-dar and his ilk.

So, you'd have to check if the ends are dashes, if you didn't want to
EsoStrings[SI_INTERACT_TITLE_FORMAT] = <<1>> to just remove them always

Last edited by eventHandler : 04/16/18 at 06:47 AM.
 
04/16/18, 10:34 AM   #7
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,566
Originally Posted by eventHandler View Post
The reason I wouldn't use GetUnitName(), is because it's so specific and not re-usable; it doesn't provide any insight into how to find other information through trial and error. Whereas :GetText() works for a lot of different classes, and provides subtle insight into the lua language concepts.
Careful. If what you want is exactly the name of the NPC (e.g. for data collection) you should definitely use the underlying API method GetUnitName in order to obtain that information, otherwise you can easily run into compatibility issues with other addons that change the formatting of the displayed name for example. On the other hand if you just want to mirror the control so the name is shown in a second place, you'd better use GetText instead, because then you automatically have the same changes from other addons applied without them needing to know about your addons functionality.

Aside from that you should be aware that GetText, classes and controls are not Lua language concepts. They are entirely ZOS' way of doing things in the UI.

Originally Posted by eventHandler View Post
So, you'd have to check if the ends are dashes, if you didn't want to
EsoStrings[SI_INTERACT_TITLE_FORMAT] = <<1>> to just remove them always
Never even think about doing that! Changing the EsoStrings tables directly like that is a very bad idea and calls for all kinds of trouble. It could easily break other addons.
 
04/16/18, 11:37 AM   #8
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 408
Originally Posted by sirinsidiator View Post

Never even think about doing that! Changing the EsoStrings tables directly like that is a very bad idea and calls for all kinds of trouble. It could easily break other addons.
I agree! Especially don't unilaterally change thousands of them all at once for an April Fools joke like some devs.
 
04/16/18, 01:55 PM   #9
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Originally Posted by Dolgubon View Post
I agree! Especially don't unilaterally change thousands of them all at once for an April Fools joke like some devs.
Good one
 
04/17/18, 01:37 AM   #10
manavortex
 
manavortex's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 138
I agree! Especially don't unilaterally change thousands of them all at once for an April Fools joke like some devs.
<coughs>Let the Isles bleed into to Nirn</coughs>
 
04/17/18, 07:53 AM   #11
eventHandler
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 12
Originally Posted by sirinsidiator View Post
Careful. If what you want is exactly the name of the NPC (e.g. for data collection) you should definitely use the underlying API method GetUnitName in order to obtain that information, otherwise you can easily run into compatibility issues with other addons that change the formatting of the displayed name for example. On the other hand if you just want to mirror the control so the name is shown in a second place, you'd better use GetText instead, because then you automatically have the same changes from other addons applied without them needing to know about your addons functionality.

Aside from that you should be aware that GetText, classes and controls are not Lua language concepts. They are entirely ZOS' way of doing things in the UI.
Ah, yes. I should have said something more like "ESO's API design philosophy while opting for generic code reusability"; you're completely right, though, in sentiment and syntax. And honestly, in the OP's use case, GetUnitName() is seemingly the better approach.

Originally Posted by sirinsidiator View Post
Never even think about doing that! Changing the EsoStrings tables directly like that is a very bad idea and calls for all kinds of trouble. It could easily break other addons.
Hence, I admitted the OP would need to check for whether or not the string had edge dashes, instead of just (for example) local name = ZO_InteractWindowTargetAreaTitle:GetText(); name = string.sub(name, 2, #name-2) etc, and didn't advise using EsoString changes for this situation.

As for never using EsoStrings, well the entire premise of my own addon is to alter the contents of ZO_InteractWindowTargetAreaTitle (and the other two text areas) for every single chatter interaction in substantial ways, and by necessity has to break any other addons trying to alter the same things. It does lend more weight to the merits of using GetUnitName() over GetText(), at least for anyone reading the names who doesn't want to check the data first; but, that would also reduce compatibility in some cases, if for example, the name is show somewhere new during dialog and now is missing the custom fonts and colors. But since I reset everything to default states when chatter interactions are ending, it really only can conflict in the space where my addon has to win.

So, I've got to agree to disagree on that final point about never thinking about using EsoStrings. We agree that usually it's a bad idea, and that addons should always be working inside their own local scope as much as possible.

Edit: If it wasn't clear, I wasn't arguing that using EsoStrings is the best method or even that it should be used; I was proposing that there are cases where it would make sense, and so never is too strong of a qualifier.

Last edited by eventHandler : 04/17/18 at 08:10 AM.
 
04/17/18, 09:31 AM   #12
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 408
Originally Posted by eventHandler View Post
Ah, yes. I should have said something more like "ESO's API design philosophy while opting for generic code reusability"; you're completely right, though, in sentiment and syntax. And honestly, in the OP's use case, GetUnitName() is seemingly the better approach.



Hence, I admitted the OP would need to check for whether or not the string had edge dashes, instead of just (for example) local name = ZO_InteractWindowTargetAreaTitle:GetText(); name = string.sub(name, 2, #name-2) etc, and didn't advise using EsoString changes for this situation.

As for never using EsoStrings, well the entire premise of my own addon is to alter the contents of ZO_InteractWindowTargetAreaTitle (and the other two text areas) for every single chatter interaction in substantial ways, and by necessity has to break any other addons trying to alter the same things. It does lend more weight to the merits of using GetUnitName() over GetText(), at least for anyone reading the names who doesn't want to check the data first; but, that would also reduce compatibility in some cases, if for example, the name is show somewhere new during dialog and now is missing the custom fonts and colors. But since I reset everything to default states when chatter interactions are ending, it really only can conflict in the space where my addon has to win.

So, I've got to agree to disagree on that final point about never thinking about using EsoStrings. We agree that usually it's a bad idea, and that addons should always be working inside their own local scope as much as possible.

Edit: If it wasn't clear, I wasn't arguing that using EsoStrings is the best method or even that it should be used; I was proposing that there are cases where it would make sense, and so never is too strong of a qualifier.
Actually, for that you can hook the SetText function rather than changing EDOStrings
 

ESOUI » Developer Discussions » Wish List » [outdated] ZO_InteractionManager:GetChattererName()

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