Originally Posted by Edda
And now for another basic noob question : how do I actually use an event in the fired function ?
I have
Code:
EVENT_MANAGER:RegisterForEvent("MXPV", EVENT_PLAYER_COMBAT_STATE, MXPV.GetCombatState);
Now I want to check if EVENT_PLAYER_COMBAT_STATE is true or false -> documentation says -> (bool inCombat).
I tried
Code:
EVENT_MANAGER:RegisterForEvent("MXPV", EVENT_PLAYER_COMBAT_STATE, MXPV.GetCombatState(event));
|
MXPV.GetCombatState <-- assigns this function to the event handler
MXPV.GetCombatState(event) <-- calls this function with event as the first argument and assigns the result of that function call to the event handler
You want this:
Lua Code:
function MXPV.GetCombatState(event, inCombat)
if inCombat then
--do stuff
end
end
EVENT_MANAGER:RegisterForEvent("MXPV", EVENT_PLAYER_COMBAT_STATE, MXPV.GetCombatState)
or this:
Lua Code:
EVENT_MANAGER:RegisterForEvent("MXPV", EVENT_PLAYER_COMBAT_STATE, function(event, inCombat)
if inCombat then
MXPV.GetCombatState(inCombat)
end
end)