Originally Posted by candrid
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:
if firstTimeLogin and sv.version ~= addon.version then welcomeFrame:Show() or UIFrameFadeIn(welcomeFrame,1,0,1) sv.version = addon.version 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:
local function OnEvent(self,event,...)
-- create variables from the event arguments
local login,reload = ...
-- if this is the first time entering the world
if event == "PLAYER_ENTERING_WORLD" and login == true then
local version = GetAddOnMetadata(<addonName>, "Version"))
if version ~= <SavedVariablePerCharacterTable>.version then
<Show Your Splash Frame and fill any of the UI with its required data>
-- Then Update the saved variable table for the character with the new version
<SavedVariablePerCharacterTable>.version = version
end
end
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.