View Single Post
04-07-12, 12:32 AM   #17
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
1. PLAYER_ENTERING_WORLD does not fire when you change zones. It only fires after you see a login screen, so it fires when you log in, reload the UI, enter an instance, leave an instance, or change continents (eg. take a zeppelin or boat through a loading screen). If you want to detect when the player changes zones, you need to register for ZONE_CHANGED_NEW_AREA, ZONE_CHANGED, and/or ZONE_CHANGED_INDOORS. See the map events page on Wowpedia for a description of each event.

2. If you still believe you're seeing issues with AceEvent-3.0 and PLAYER_ENTERING_WORLD, try using a simple test addon with debug prints to see what's going on:
Lua Code:
  1. local addon = LibStub("AceAddon-3.0"):NewAddon("ToggleTestAddon", "AceEvent-3.0")
  2.  
  3. function addon:OnInitialize()
  4.     print("OnInitialize")
  5.     self:RegisterEvent("PLAYER_ENTERING_WORLD")
  6.     -- Normally you would only register events in OnEnable, and then
  7.     -- disable them in OnDisable, but for this test we want the event
  8.     -- to always be registered regardless of the addon's enabled state.
  9. end
  10.  
  11. function addon:OnEnable()
  12.     print("OnEnable")
  13. end
  14.  
  15. function addon:OnDisable()
  16.     print("OnDisable")
  17. end
  18.  
  19. function addon:PLAYER_ENTERING_WORLD()
  20.     print("PLAYER_ENTERING_WORLD", self:IsEnabled() and "enabled" or "disabled")
  21. end
  22.  
  23. function addon:Toggle()
  24.     print("Toggle")
  25.     if self:IsEnabled() then
  26.         print("Disable")
  27.         self:Disable()
  28.     else
  29.         print("Enable")
  30.         self:Enable()
  31.     end
  32. end
  33.  
  34. SLASH_TOGGLETEST1 = "/toggletest"
  35. SlashCmdList.TOGGLETEST = function() return addon:Toggle() end
Type "/toggletest" in-game to toggle the enabled state of the test addon. Watch for debug messages in the chat frame when the addon is loaded, enabled, or disabled; and whenever the PLAYER_ENTERING_WORLD event fires. Try zoning in and out of an instance a few times with the addon enabled, then again a few times with it disabled.

If the test addon works as expected (eg. always receives the event) then there is something wrong in your code, and you will need to post your full code if you want any further help with the problem.

If it does not work as expected, report back with a description of its behavior.
  Reply With Quote