- edited description
Allow managing saved variables from inside a script
Managing saved variables would be a great thing for libraries. You could add something like
function SavedVariables.Add( string ) -- returns void
function SavedVariables.Remove( string ) -- returns bool
function SavedVariables.Set( string, value ) -- returns void
function SavedVariables.Get( string ) -- returns value
function SavedVariables.IsSaved( string ) -- returns bool
SavedVariables.Add
adds a variable to the set of variables that should be saved. The argument is the identifier of that variable.
SavedVariables.Remove
removes a variable from the set of variables that should be saved and returns if the operation succeeded. The argument is the identifier of that variable.
SavedVariables.Set
sets the saved value of a saved variable. This could be used for library-script interaction or setting flags. The first argument is the identifier of the variable, the second is the value that should be set.
SavedVariables.Get
gets the saved value of a saved variable. This could also be used for library-script interaction or checking for flags. The argument is the identifier of the variable.
SavedVariables.IsSaved
checks if the variable is registered in the saved variables set. The argument is the identifier of the variable.
Comments (6)
-
reporter -
reporter - marked as proposal
set bug kind from "enhancement" to "proposal"
-
What would be the benefits of this over the existing system?
One issue I see with this system is that you are in charge of making sure the variable you want to save is always up to date, and you can't always ensure that (for example when the script crashes).
-
reporter First of all, I don't want the old system to be replaced, I want it to be, well, extended.
Regard this as some, well, counterpart of Java reflection. You could do something like this:
if(SavedVariables.IsSaved( "someLibraryVariable" )) then -- do some library-specific operations here -- such as method calls end
Actually, something like this might be a good idea for cross-script interaction in case there is the possibility to run multiple scripts at once. Kind of DLC-like scripts that are optional but can be installed and are automatically integrated into the main script. As an alternative, you could (re)implement some sort of custom script loading.
Besides that, having some sort of "recovery point" is also good, especially because this would allow (some) saved variables to be updated manually.
-
reporter - changed status to closed
-
reporter - changed status to wontfix
- Log in to comment
improved and expanded the description