KillingBlow.CheckForApGain() doesn't trigger the event -- none of the parameters are filled in.
You need to actually register it with an event handler to call.
Does the AP gain event always fire before or after the combat event? If so, you can do something like this to check when the last AP gain was:
Lua Code:
local delta = 1 --If events happen within this time, call simultaneous
local lastApGain = nil
function KillingBlow.CheckForApGain( alliancePoints, playSound, difference)
lastApGain = GetTimeStamp() --or a higher precision, maybe GetFrameTimeMilliseconds would work
end
function KillingBlow.Combat(eventCode, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log)
if ... then --Other filtering you were doing here for source damage, etc
if lastApGain and GitDiffBetweenTimestamps(GetTimeStamp(), lastApGain) > delta then
--Create your popup frame
end
end
end
em:RegisterForEvent(self.addonName, EVENT_COMBAT_EVENT, KillingBlow.Combat )
em:RegisterForEvent(self.addonName, EVENT_ALLIANCE_POINT_UPDATE, KillingBlow.CheckForApGain)
If it's the other way around (combat event always fires first), you can cache the data on a COMBAT event and create the popup on the AP_GAIN event.
If you need values from both, or the events can fire in either order, it's a little bit trickier, but the basic pattern would be:
Code:
--Pseudocode:
EVENT1:
save parameters
save timestamp
call FIRE function
EVENT2:
save parameters
save timestamp
call FIRE function
FIRE:
if timestamps close enough then
do whatever with saved parameters
end
-----------------------------------------
Also, playerName == sourceName will fail for female characters and possibly in the FR or DE clients. Use one of the ZO format functions or a :gsub("%^..$","") to remove from the source name to check.