Why would I want to use preHook instead of a regular d() ?
Here is my code atm :
Code:
myAddon = {}
myAddon.name = "myAddon"
function myAddon.Initialize()
myAddon.weaponSheathed = ArePlayerWeaponsSheathed()
EVENT_MANAGER:RegisterForUpdate(myAddon.name, 1000 ,myAddon.OnPlayerSheathedState)
end
function myAddon.OnPlayerSheathedState(weaponSheathed)
if weaponSheathed ~= myAddon.weaponSheathed then
-- update the stored state
myAddon.weaponSheathed = weaponSheathed
if weaponSheathed then
d("Weapons are Sheathed.")
else
d("Weapons are Drawn.")
end
end
end
-- event handler function which will be called when the "addon loaded" event occurs. Initialize our addon after all of its resources are fully loaded.
function myAddon.OnAddOnLoaded(event, addonName)
-- initialize only when OUR addon is loaded
if addonName == myAddon.name then
myAddon:Initialize()
end
end
-- register our event handler function to be called when the proper event occurs.
EVENT_MANAGER:RegisterForEvent(myAddon.name, EVENT_ADD_ON_LOADED, myAddon.OnAddOnLoaded)
The problem is "Weapons are Drawn." is written every second, like the if statement is constantly false...
I don't want to use the function "isUnitInCombat" because the chat message will not occur when I draw/sheath weapons.