View Single Post
11-21-20, 07:16 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Try moving OnReady from ADDON_LOADED to PLAYER_LOGIN. Your SavedVariables will have been loaded by the game when this event fires and it only fires once.

Don't forget to remove your old SV .lua file(s) before trying.

Lua Code:
  1. function BattleDex.OnReady()
  2.     -- init database
  3.     if not BattleDexDB then
  4.         BattleDexDB = {
  5.             pets = {},
  6.         }
  7.     end
  8.     if not BattleDexPrefs then
  9.         BattleDexPrefs = {}
  10.         for k,v in pairs(BattleDex.default_options) do
  11.             if not BattleDexPrefs[k] then
  12.                 BattleDexPrefs[k] = v
  13.             end
  14.         end
  15.     end
  16.     GameTooltip:HookScript("OnTooltipSetUnit", BattleDex.AlterTooltip);
  17. end
  18.  
  19. function BattleDex.OnEvent(frame, event, ...)
  20.     if (event == 'PLAYER_LOGIN') then
  21.         BattleDex.OnReady();
  22.     end
  23.  
  24.     if (event == 'PET_BATTLE_OPENING_DONE') then
  25.         BattleDex.RecordBattle();
  26.     end
  27. end
  28.  
  29. -- ...
  30.  
  31. BattleDex.EventFrame:RegisterEvent("PLAYER_LOGIN");
  32. BattleDex.EventFrame:RegisterEvent("PET_BATTLE_OPENING_DONE");
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 11-21-20 at 07:43 PM.
  Reply With Quote