Thread: Fading Textures
View Single Post
08-18-18, 06:50 PM   #23
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Line 4:
addonData will never be empty or nil (unless there is serious issue with the WoW client, in which case you have greater worries than just your addon)

This -is- what you want to do when initializing your saved variables table, however. If it already exists, you don't want to overwrite it with an empty table. This also means that you have to wait until your addon's variables load (or later) to see if they exist yet and to do something with them if they do.

Lua Code:
  1. local addonName, addonTable = ...
  2.  
  3. local version = GetAddonMetadata(addonName, "Version")
  4.  
  5. local f = CreateFrame("Frame")
  6. f:RegisterEvent("VARIABLES_LOADED")
  7. f:SetScript("OnEvent", function(self, event, arg1)
  8.           if event == "VARIABLES_LOADED" and arg1 = addonName then
  9.                PawDB = PawDB or {}
  10.                if not PawDB.version or PawDB.version ~= version then
  11.                     --show your splash screen
  12.                end
  13.                PawDB.version = version
  14.           end
  15.      end)


(PS - If you want to do something only when the player logs in and not whenever they see a loading screen, there are 2 ways to do that.
  1. use PLAYER_LOGIN instead of PLAYER_ENTERING_WORLD
  2. unregister the PLAYER_ENTERING_WORLD event when it is no longer needed
)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote