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:
local addonName, addonTable = ...
local version = GetAddonMetadata(addonName, "Version")
local f = CreateFrame("Frame")
f:RegisterEvent("VARIABLES_LOADED")
f:SetScript("OnEvent", function(self, event, arg1)
if event == "VARIABLES_LOADED" and arg1 = addonName then
PawDB = PawDB or {}
if not PawDB.version or PawDB.version ~= version then
--show your splash screen
end
PawDB.version = version
end
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.
- use PLAYER_LOGIN instead of PLAYER_ENTERING_WORLD
- unregister the PLAYER_ENTERING_WORLD event when it is no longer needed
)