ID:273131
 
Hello,
Is there a way to store any given object's variables into a string or list and then restore them at given time?
obj/var/StoredString

obj/proc/StoreVariables()
src.StoredString=initial(src.StoredString)
for(var/v in src.vars)
if(src.vars[v]!=initial(src.vars[v]) && issaved(src.vars[v])) src.StoredString+="&[v]=[src.vars[v]]"
src.StoredString=copytext(src.StoredString,2)

obj/proc/RestoreVariables()
var/list/Params=params2list(src.StoredString)
for(var/v in Params) src.vars[v]=Params[v]
Mr.DJ7 wrote:
Hello,
Is there a way to store any given object's variables into a string or list and then restore them at given time?

Run a for loop through the atom's vars...
for(var/X in vars)
world<<"MAH VAR! [X]: [vars[X]]"
List+=X
List[X]=vars[X]



They would be restored in a similar manner. Bear in mind that there are certain vars that you can NOT change, and trying to do so will cause errors. You will want to add a check to make sure you aren't screwing anything up.
You could put savefile.ImportText() and savefile.ExportText() to good use.