View Single Post
06/30/18, 02:23 PM   #12
SDPhantom
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 47
Originally Posted by votan View Post
Maybe the author can mark a savedVar as dirty. The authors know best, if a critical change was made.
In Dan's example, running the manual save function registers the saved var to be picked up later by this process. What part of that isn't marking it as dirty?



Originally Posted by Sorondor View Post
What would really be nice is if specific keys could be marked dirty and only those keys saved during an autosave cycle. However, I have no idea if it's possible to write to SavedVars in part or if it must be written whole every single time.
I highly doubt writing only specific keys would even be possible. Lua memory doesn't look like the code you see in the saved var files. It also doesn't have any stock method of turning data into such code. This is where a serializer comes in. A serializer takes data you give it and encodes it into some sort of string that can be read in by a deserializer to reconstruct the original data later. The serializer for saved vars takes the entire table and writes it into Lua code that can be read in by loadfile() as the deserializer.

If an attempt were to be made, the original file would have to be analyzed with a tokenizer to find where the original data for the key/value pair is in the file to replace it. This would take up a lot more processing than just overwriting the entire thing.

Last edited by SDPhantom : 06/30/18 at 02:26 PM.
  Reply With Quote