View Single Post
07/24/18, 12:20 AM   #17
HailTheMoons
 
HailTheMoons's Avatar
Join Date: Jul 2018
Posts: 8
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:
  1. myAddon = {}
  2. myAddon.name = "myAddon"
  3.  
  4. function myAddon.Initialize()
  5.     myAddon.weaponSheathed = ArePlayerWeaponsSheathed()
  6.     EVENT_MANAGER:RegisterForUpdate(myAddon.name, 200 ,myAddon.OnPlayerSheathedState)
  7. end
  8.  
  9.  
  10. function myAddon.OnPlayerSheathedState()
  11.     if myAddon.weaponSheathed ~= ArePlayerWeaponsSheathed() then
  12.         -- update the stored state
  13.         myAddon.weaponSheathed = ArePlayerWeaponsSheathed() -- invert the boolean would be more optimized ?
  14.  
  15.         if myAddon.weaponSheathed then
  16.             d("Weapons are Sheathed.")
  17.         else
  18.             d("Weapons are Drawn.")
  19.         end
  20.     end
  21. end
  22.  
  23. -- event handler function which will be called when the "addon loaded" event occurs. Initialize our addon after all of its resources are fully loaded.
  24. function myAddon.OnAddOnLoaded(event, addonName)
  25. -- initialize only when OUR addon is loaded
  26. if addonName == myAddon.name then
  27. myAddon:Initialize()
  28. end
  29. end
  30.  
  31. -- register our event handler function to be called when the proper event occurs.
  32. EVENT_MANAGER:RegisterForEvent(myAddon.name, EVENT_ADD_ON_LOADED, myAddon.OnAddOnLoaded)
  Reply With Quote