I'm gonna stick with the code below for know, and work on graphics outputs.
I am still interested on some full code exemples of ZO_Prehook from the pros.
It's just that I don't want to be stuck for too long on this part.
Best regards
Lua Code:
myAddon = {}
myAddon.name = "myAddon"
function myAddon.Initialize()
myAddon.weaponSheathed = ArePlayerWeaponsSheathed()
EVENT_MANAGER:RegisterForUpdate(myAddon.name, 200 ,myAddon.OnPlayerSheathedState)
end
function myAddon.OnPlayerSheathedState()
if myAddon.weaponSheathed ~= ArePlayerWeaponsSheathed() then
-- update the stored state
myAddon.weaponSheathed = ArePlayerWeaponsSheathed() -- invert the boolean would be more optimized ?
if myAddon.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)