Thread Tools Display Modes
07-30-15, 09:04 AM   #1
pbutter
A Defias Bandit
Join Date: Jul 2015
Posts: 2
Question How to run lua function when joining a group?

Hi

I just got into creating addons and I made one where it warns me if I have Glyph of Untamed Stars active when in a group, but this only runs OnLoad and I'm kind of lost as to where I can find information on how to get this to run when joining a group.

Thanks for you time!
  Reply With Quote
07-30-15, 10:45 AM   #2
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Hey, use /eventtrace to track events in the game. Can't check right now, but using that tool you should be able to find which event fires when you join a group.

Here's a list of events:
http://wowprogramming.com/docs/events

Using something like this to catch it:

Lua Code:
  1. local function EventHandler (self, event, ...)
  2.     if  self[event] then
  3.         self[event](self, ...)
  4.     end
  5. end
  6.  
  7. local f = CreateFrame("FRAME", "MyAddon", UIParent)
  8.  
  9. function f:ADDON_LOADED(...)
  10.     -- do stuff when loaded
  11. end
  12.  
  13. function f:PLAYER_LOGOUT(...)
  14.     -- do stuff when you log out
  15. end
  16.  
  17. function f:PLAYER_STARTED_MOVING(...)
  18.     -- do stuff when you start moving
  19. end
  20.  
  21. f:RegisterEvent("ADDON_LOADED")
  22. f:RegisterEvent("PLAYER_LOGOUT")
  23. f:RegisterEvent("PLAYER_STARTED_MOVING")
  24. f:SetScript("OnEvent", EventHandler)
__________________

Last edited by MunkDev : 07-31-15 at 12:11 AM.
  Reply With Quote
07-30-15, 08:13 PM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
GROUP_ROSTER_UPDATE is the event that fires. Note that it can fire twice, once when you join a group, and again when your group joins a larger group. The event also fires whenever someone joins, leaves, etc.

As always, check documentation and related APIs.
  Reply With Quote
08-03-15, 11:42 AM   #4
pbutter
A Defias Bandit
Join Date: Jul 2015
Posts: 2
Thanks guys!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to run lua function when joining a group?

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