ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Wish List (https://www.esoui.com/forums/forumdisplay.php?f=177)
-   -   [outdated] ZO_InteractionManager:GetChattererName() (https://www.esoui.com/forums/showthread.php?t=7713)

manavortex 04/09/18 12:13 AM

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


sirinsidiator 04/09/18 04:03 AM

Did you try GetUnitName("interact")? I use that to get the name of trader NPCs while chatting with them and it works just fine.

manavortex 04/09/18 04:05 AM

mind = blown.
If that works, I have a lot less strings to parse.

eventHandler 04/13/18 02:12 PM

Quote:

Originally Posted by manavortex (Post 34342)
mind = blown.
If that works, I have a lot less strings to parse.

ZO_InteractWindowTargetAreaTitle:GetText()

Dolgubon 04/13/18 07:00 PM

Quote:

Originally Posted by eventHandler (Post 34393)
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)

eventHandler 04/16/18 06:09 AM

Quote:

Originally Posted by Dolgubon (Post 34396)
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

sirinsidiator 04/16/18 10:34 AM

Quote:

Originally Posted by eventHandler (Post 34412)
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.

Quote:

Originally Posted by eventHandler (Post 34412)
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.

Dolgubon 04/16/18 11:37 AM

Quote:

Originally Posted by sirinsidiator (Post 34414)

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.

Baertram 04/16/18 01:55 PM

Quote:

Originally Posted by Dolgubon (Post 34416)
I agree! Especially don't unilaterally change thousands of them all at once for an April Fools joke like some devs.

:D:D:D Good one

manavortex 04/17/18 01:37 AM

Quote:

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

eventHandler 04/17/18 07:53 AM

Quote:

Originally Posted by sirinsidiator (Post 34414)
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.

Quote:

Originally Posted by sirinsidiator (Post 34414)
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.

Dolgubon 04/17/18 09:31 AM

Quote:

Originally Posted by eventHandler (Post 34421)
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


All times are GMT -6. The time now is 09:26 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI