WoWInterface - View Single Post - Fading Textures
Thread: Fading Textures
View Single Post
08-16-18, 11:38 AM   #15
nUI Maintainer
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,488
Originally Posted by candrid View Post
I am sorry to ask but could you elaborate on this example? I do not understand the sv.version segment. Also, in many versions of my code here, offline I cannot get the SavedVariablesPerCharacter to do anything.

Originally Posted by Xrystal View Post
Something like the following
Lua Code:
Lua Code:
  1. if firstTimeLogin and sv.version ~= addon.version then
  2.    welcomeFrame:Show() or UIFrameFadeIn(welcomeFrame,1,0,1)
  3.    sv.version = addon.version
  4. end
The SavedVariablesPerCharacter section in the toc file will create a table of that name in the WTF\Account\<AccountName>\<ServerName>\<CharacterName>\SavedVariables\<addonName>.lua file.

sv.version is just an example of variable ( item in the savedvariable table) connected to the sv value which is just what I put to show that you use your savedvariable table in place of sv.

addon.version is a similar thing but is just pointing to a variable in your addon code holding a copy of your addon version which can be retrieved using GetAddOnMetadata function as the following example shows.

<...> shows what has to be replaced with what is your addon's equivalent

Lua Code:
  1. local function OnEvent(self,event,...)
  2.    -- create variables from the event arguments
  3.    local login,reload = ...
  4.    -- if this is the first time entering the world
  5.    if event == "PLAYER_ENTERING_WORLD" and login == true then
  6.       local version = GetAddOnMetadata(<addonName>, "Version"))
  7.       if version ~= <SavedVariablePerCharacterTable>.version then
  8.          <Show Your Splash Frame and fill any of the UI with its required data>
  9.          -- Then Update the saved variable table for the character with the new version
  10.          <SavedVariablePerCharacterTable>.version = version
  11.      end
  12.   end
  13. end

You may also get away with using PLAYER_LOGIN which should only happen the first time you log in. But it would depend on what information you need and its availability at that time. PLAYER_ENTERING_WORLD tends to be the event used for this reason so thankfully they have added those two parameters to the event to make things easier to identify between a fresh login and a reload/loading screen.

I hope that helps make a bit more sense of what I was trying to explain.
  Reply With Quote