Condition for when the player has joined a covenant?
I want to do the following if the player hasn't joined a covenant:
local function LoadMinimap() if not player.has.covenant then GarrisonLandingPageMinimapButton:ClearAllPoints() end end How do I put that criteria down properly in the if condition? |
A quick glance through the API reveals the COVENANT_CHOSEN event. Have a look to see if it fits your bill.
|
How do I make that reference the player?
Lua Code:
Like this? |
No, it is an event, which means you need to handle it.
|
To find out if a player has or has not joined a Covenant, handle the event, and if the argument == 0 then the player has not joined, so do whatever. If the argument is >= 1 =< 4 then the player has joined and the event tells you which Covenant, so do something else.
|
Since that is an event, doesn't it only happen when the player chooses a covenant? Or is it an event that happens all the time?
|
Quote:
|
I'm trying to debug this so I can learn how to handle an event properly
I put the covenant event handler within a code that disables spell activation overlay just to see how it works Lua Code:
The only message I get in-game is Code:
11:33:15 | Hello World! Hello PLAYER_ENTERING_WORLD |
I'd check out C_Covenants.GetActiveCovenantID(). You can also look at the other covenant functions here.
PS: COVENANT_CHOSEN only fires if the choice is made in the current session. Otherwise, use PLAYER_LOGIN as that signals most character data should be available by then. |
Quote:
If not then how do I use it? |
Quote:
So create a variable for the addon such as covenantID and then update it with the appropriate value from C_Covenants.GetActiveCovenantID() on PLAYER_LOGIN or when the COVENANT_CHOSEN event fires. You can then use the variable for checks elsewehere in the addon. |
I think I got something to work!
I was testing in-game and wrote this /script local covenantID=C_Covenants.GetActiveCovenantID(); print(covenantID); The game returned me the value 4, which should be accurate since my character has chosen Necrolord I'll try to work from here and if I end up having any issues I'll post again. Thanks for helping! |
All times are GMT -6. The time now is 12:35 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI