Thread: Fading Textures
View Single Post
08-16-18, 09:57 PM   #18
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
You have to initialise your saved variables .. by default they will be nil.

Near the top of your addon's lua file you need set the base values

-- This will create a new table containing no values
<SavedVariablePerCharacterTable> = {}

-- This will set the version variable to nil so that the first test will cause the splash to appear.
<SavedVariablePerCharacterTable>.version = nil

By the time PLAYER_ENTERING_WORLD is called your saved variables should be loaded in memory

So, using your example you posted this is how I would code it. See how this works out for you. Login a few times without changing the Version field in the TOC and then a few times after changing it ... the splash should only appear after it is changed.

Lua Code:
  1. local addonName, addonData = ...
  2.  
  3. -- Force initialisation in case there are no saved variables yet
  4. -- These should get overriden when the saved variables are loaded
  5. PawDB = {}
  6. PawDB.version = nil
  7.  
  8. -- Event function
  9. local function OnEvent(self,event,...)
  10.  
  11.       -- create variables from the event arguments
  12.       local login,reload = ...
  13.  
  14.         -- if this is the first time entering the world
  15.         if event == "PLAYER_ENTERING_WORLD" and login == true then
  16.            local version = GetAddOnMetadata("PawsUI", "Version")
  17.             if version ~= PawDB.version then
  18.                 -- Show the Splash Frame and fill any of the UI with its required data
  19.                 self:SetSize(850, 480); -- the size of the splash
  20.                 self:SetPoint("CENTER"); -- its position on the screen            
  21.                 UIFrameFadeIn(self,1,0,1);
  22.  
  23.                 -- Then Update the saved variable table for the character with the new version
  24.                 PawDB.version = version
  25.            end
  26.       end
  27.  end
  28.  
  29. -- Create the frame and set which events to monitor and which function will respond to it
  30. local InstallerLogo = CreateFrame("Frame", addonName.."ILogo", UIParent);
  31. InstallerLogo:RegisterEvent("PLAYER_ENTERING_WORLD");
  32. InstallerLogo:SetScript("OnEvent", OnEvent)
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote