Thread Tools Display Modes
05-13-14, 03:43 PM   #1
bublix
A Defias Bandit
Join Date: May 2014
Posts: 3
Question Get selected gossip index

Hey there,

I'm trying to find out how to get the selected gossip index.

If you talk to a Stormwind City Guard you can choose serveral options like "Auction House", "Bank of Stromwind", "Stormwind Harbor", ...

If I click on on of these items, the event "GOSSIP_CONFIRM_CANCLE" will be thrown. The problem is: The event has no parameters....

Is it possible to get the selected index?

Thanks in advance,
bublix
  Reply With Quote
05-13-14, 03:47 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You can either hook the SelectGossip function, or hook the buttons' OnClick scripts. What are you actually trying to achieve, functionality-wise?
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
05-14-14, 12:01 AM   #3
bublix
A Defias Bandit
Join Date: May 2014
Posts: 3
Thanks for the quick reply. I'm trying to get the Index to send it to another character, that he can use it with "SelectGossipOption(index)".

Unfortunately I don't know wehre the function "SelectGossip()" is stored.
  Reply With Quote
05-14-14, 05:33 AM   #4
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
There are 3 different functions depending on the type of gossip dialog from the npc: SelectGossipActiveQuest, SelectGossipAvailableQuest, and SelectGossipOption.

It sounds like you're probably interested in the SelectGossipOption function, so to hook it all you need to do is something like this..
Lua Code:
  1. hooksecurefunc('SelectGossipOption', print)
or
Lua Code:
  1. hooksecurefunc('SelectGossipOption', function(index, text, confirm)
  2.     print('Gossip index selected:', index)
  3. end)
  Reply With Quote
05-14-14, 07:58 AM   #5
bublix
A Defias Bandit
Join Date: May 2014
Posts: 3
Well, thats basically it.

I had never expected, that it's so simple.

Thanks to you guys!

Edit:
Here is another solution.
(I need to do stuff before the hooked function)
Lua Code:
  1. function New_SelectGossipOption(index, text, confirm)
  2.     print('Before')
  3.     Old_SelectGossipOption(index, text, confirm)
  4.     print('After')
  5. end
  6.  
  7. Old_SelectGossipOption = SelectGossipOption
  8. SelectGossipOption = New_SelectGossipOption

Last edited by bublix : 05-14-14 at 03:32 PM. Reason: Another solution
  Reply With Quote
05-15-14, 06:18 AM   #6
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
I know it looks like a great idea to override SelectGossipOption

But in the long run this could cause taint so bad that you break UI functionality, that's the worst case.

Instead you should use hooksecurefunc or hook widget objects like with HookScript and do something after certain functions are called, or if you want to change the behavior you should change the behavior by editing the (in this case) Gossip Frame instead of affecting all elements utilizing SelectGossipOption.

Anyway semlar had good examples how to just read what options were picked by the user, without breaking anything. This way you can read what index was selected, then do what ever you wanna do with it.
__________________
Profile: Curse | Wowhead
  Reply With Quote
05-15-14, 11:12 AM   #7
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
If you HAVE to pre-hook it, I would attempt to hook the gossip button's preclick event first because overwriting the blizzard function is going to cause taint which will probably have consequences (like breaking buttons in the interface).
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Get selected gossip index

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