SavedVariablesPerCharacter
I was able to successfully create the file to save the variables of my addon.
Code:
## SavedVariablesPerCharacter: MyAddon_Settings |
This should help you.
http://www.wowpedia.org/Saving_varia..._game_sessions |
I cleaned up that wiki page some to remove some really outdated information, so it should be relevant again now. If you read it before now, I'd suggest going back to re-read it, and then removing any references to the VARIABLES_LOADED event from your addon (use ADDON_LOADED where arg1 is the folder name of your addon instead) and probably removing PLAYER_LOGOUT (it's completely unnecessary for the vast majority of addons).
Also, if you want to use a table to hold multiple variables, here is a simple function you can use to initialize your default values. It works no matter how many levels of sub-tables are in your defaults. Code:
-- Define your default table: |
MyAddonSavedVariables is the file specified in line ## SavedVariablesPerCharacter:?
|
There is no control over the actual file it writes to or where it's located, just what global variables WoW stores in it. To shorten Phanx's explanation, the SavedVariablesPerCharacter directive just tells WoW what globals to save for your addon. These globals will be available when ADDON_LOADED fires for your addon.
|
Code:
local addon = CreateFrame("Frame", "MyAddon") Code:
local addon = CreateFrame("Frame", "MyAddon") |
Quote:
|
Quote:
|
Code outside of a function runs immediately when WoW reads your file.
Code inside of a function does not run until that function is called. In your example, the code inside the function you set as your frame's OnEvent script does not run until the game fires the ADDON_LOADED event with your addon's name as the first argument. That happens after all of your addon's files and saved variables have been read. |
Quote:
PLAYER_LOGIN similar ? So I can save to check with ADDON_LOADED the arg1 ... |
I did something like this to check if the addon db was in an old format and eventually convert.
Lua Code:
|
Quote:
The purpose of PLAYER_LOGIN is to tell addons that all unit-specific data for the player is now available, like UnitName(). This fires only once and might not fire when the UI is reloaded. If an addon is LoD, it may never see this event at all. ADDON_LOADED is specifically meant for this procedure. It signals the entire environment that an addon has finished loading and all global API and saved data provided by said addon is now available. |
Understood :-)
|
All times are GMT -6. The time now is 05:19 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI