mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 15:50:20 +00:00
feat: add SavedVariables persistence for Lua addons
Addons can now persist data across sessions using the standard WoW
SavedVariables pattern:
1. Declare in .toc: ## SavedVariables: MyAddonDB
2. Use the global in Lua: MyAddonDB = MyAddonDB or {default = true}
3. Data is automatically saved on logout and restored on next login
Implementation:
- TocFile::getSavedVariables() parses comma-separated variable names
- LuaEngine::loadSavedVariables() executes saved .lua file to restore globals
- LuaEngine::saveSavedVariables() serializes Lua tables/values to valid Lua
- Serializer handles tables (nested), strings, numbers, booleans, nil
- Save triggered on PLAYER_LEAVING_WORLD and AddonManager::shutdown()
- Files stored as <AddonDir>/<AddonName>.lua.saved
Updated HelloWorld addon to track login count across sessions.
This commit is contained in:
parent
5ea5588c14
commit
062cfd1e4a
9 changed files with 177 additions and 2 deletions
|
|
@ -693,6 +693,7 @@ void Application::setState(AppState newState) {
|
|||
// If we reuse a previously spawned instance without forcing a respawn, appearance (notably hair) can desync.
|
||||
if (addonManager_ && addonsLoaded_) {
|
||||
addonManager_->fireEvent("PLAYER_LEAVING_WORLD");
|
||||
addonManager_->saveAllSavedVariables();
|
||||
}
|
||||
npcsSpawned = false;
|
||||
playerCharacterSpawned = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue