Quantcast SavedVariables forced write - WoWInterface
Thread Tools Display Modes
03-31-20, 06:21 AM   #1
doofus
A Flamescale Wyrmkin
Join Date: Feb 2018
Posts: 126
SavedVariables forced write

I would like to save data in a file to be read externally. This is possible by assigning to a "SavedVariables" variable, but I cannot force it to write to the file on demand. Well I sort of can, by "/reload", but is there a programmatic way?
  Reply With Quote
03-31-20, 06:28 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,447
Originally Posted by doofus View Post
I would like to save data in a file to be read externally. This is possible by assigning to a "SavedVariables" variable, but I cannot force it to write to the file on demand. Well I sort of can, by "/reload", but is there a programmatic way?
Nope. The Saved Variables are loaded into memory on Login and saved on Logout. Addons update the memory values during game play. The file will not be updated until you either log out to character screen ( for character based saved variables ) and all the way out ( for game based saved variables ).
__________________
  Reply With Quote
03-31-20, 08:30 AM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,214
/reload also causes saved variables to be eeerrrr... saved.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
03-31-20, 02:46 PM   #4
doofus
A Flamescale Wyrmkin
Join Date: Feb 2018
Posts: 126
Therefore, if an addon wants to communicate using an external file, it can only be done with "/reload" and/or real reload?
  Reply With Quote
03-31-20, 03:20 PM   #5
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,214
The addon can't communicate but the only way for an external program to extract the latest information from an addons SavedVariables file(s) is after /reload or logout/exit.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
03-31-20, 10:45 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,920
The function you're looking for is C_UI.Reload() (previously ReloadUI()). This requires a hardware event like a button click or a keybind.

This restriction of real-time communication outside of WoW is by design to prevent botting.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 03-31-20 at 11:01 PM.
  Reply With Quote
04-01-20, 01:51 AM   #7
doofus
A Flamescale Wyrmkin
Join Date: Feb 2018
Posts: 126
Originally Posted by Fizzlemizz View Post
The addon can't communicate but the only way for an external program to extract the latest information from an addons SavedVariables file(s) is after /reload or logout/exit.
I got the idea from the well known TSM addon, where, I presume, an external application writes to the saved variables file, to be read later by the addon itself. So the communication can be two ways, albeit with the /reload in between.

I have also noticed many times that WoW loses character settings if you do not log out but crash out/lose connection, which also follows the same "save files on /reload" rule...
  Reply With Quote
04-01-20, 01:56 AM   #8
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,109
Originally Posted by doofus View Post
WoW loses character settings if you do not log out but crash out/lose connection
Of course, because that is not a "clean" exit of the game, therefore the instruction to write to disc never happens.

Think of writing the Great Novel then pressing alt-f4. Except that in WoW there is no periodic automatic save.
  Reply With Quote
04-01-20, 02:01 AM   #9
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,447
Originally Posted by myrroddin View Post
Of course, because that is not a "clean" exit of the game, therefore the instruction to write to disc never happens.

Think of writing the Great Novel then pressing alt-f4. Except that in WoW there is no periodic automatic save.

Or in the middle of writing your first game ... and the power goes before you save and that large 300 lines of code are gone in the wind ... *cries*
__________________
  Reply With Quote
04-01-20, 02:09 AM   #10
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,447
Originally Posted by doofus View Post
I got the idea from the well known TSM addon, where, I presume, an external application writes to the saved variables file, to be read later by the addon itself. So the communication can be two ways, albeit with the /reload in between.

I have also noticed many times that WoW loses character settings if you do not log out but crash out/lose connection, which also follows the same "save files on /reload" rule...

Yes, using reload in an addon ( via a button click ) or /reload command, will force an update of the saved variables. So that in the event of a crash out before the next reload you will have at least have up to the last save done. Unfortunately, any changes you make while you are still in the game will not be registered. You would have to log out ... update the file if needed ... log in. At that point it will load the updated file.

Hopefully these 3 scenarios will highlight why what you want will only work as an autosave type thing ( with a button press or slash command ) or as an external reader/writer of the file while the game is not running.

Log In > Saved Variables File Loaded into memory
Reload > Saved Variables File Updated from memory and loaded into memory
Crash .... > No change to Saved Variable File

Log In > Saved Variables File Loaded into memory
Reload > Saved Variables File Updated from memory and loaded into memory
External Program > Saved Variables File adjusted via program
Reload > Saved Variables File Updated from memory, replacing changes made by program, and then loaded into memory

Log In > Saved Variables File Loaded into memory
Log Out > Saved Variables File Updated from memory
External Program > Saved Variables File adjusted via program
Log In > Saved Variables File Loaded into memory including the changes mae by the program
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SavedVariables forced write

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off