How to do with persistent data?
by Andre Lind · in Torque Game Builder · 03/17/2007 (2:51 pm) · 4 replies
Hi!
I got a small problem regarding persistent data
I'm currently working on a RPG framework but have trouble saving my stuff between levels...
So far I've saved the needed stuff to a file on disc (i.e $party.save("./RPG/Saves/party.cs")) but I would rather do it in memory.
Is it possible?
Is it even allowed to just "dump" a SimSet with a lot of stuff to a file with save()? I mean, the file written is just a textfile with all the objects visible...
All feedback is appreciated! Thanks!
I got a small problem regarding persistent data
I'm currently working on a RPG framework but have trouble saving my stuff between levels...
So far I've saved the needed stuff to a file on disc (i.e $party.save("./RPG/Saves/party.cs")) but I would rather do it in memory.
Is it possible?
Is it even allowed to just "dump" a SimSet with a lot of stuff to a file with save()? I mean, the file written is just a textfile with all the objects visible...
All feedback is appreciated! Thanks!
#2
My $party is actually not created yet, I've used hardcoded stats this far
Now I got a pretty good idea on how to create it though!
Thanks!
03/18/2007 (6:57 am)
Thanks for the quick answer :)My $party is actually not created yet, I've used hardcoded stats this far
Now I got a pretty good idea on how to create it though!
Thanks!
#3
I do like this:
"exec: invalid script file RPG/Saves/members.cs"
If I set it directly to the myFile.dso it says there is an error on line1 - Parse error
Anyone know how to do this?
03/21/2007 (1:09 am)
Hmm, for some reason I can't get this to work the way I expected :(I do like this:
mySimObject.save("./RPG/Saves/members.cs");
compile("~/Saves/members.cs");
fileDelete("~/Saves/members.cs");But when I try to exec "~/Saves/members.cs" later it just says:"exec: invalid script file RPG/Saves/members.cs"
If I set it directly to the myFile.dso it says there is an error on line1 - Parse error
Anyone know how to do this?
#4
refreshFileCache();
and define it somewhere like this :
function refreshFileCache()
{
setModPaths(getModPaths());
}
Enjoy.
03/21/2007 (6:57 am)
Include this statement after you coderefreshFileCache();
and define it somewhere like this :
function refreshFileCache()
{
setModPaths(getModPaths());
}
Enjoy.
Associate David Higgins
DPHCoders.com
Where "..." is the file name to save as ... not sure if "deleteFile" is a real function, but one does exist, you'd have to check the TGB Reference to figure out what it's real name and calling syntax are ...
As for saving persistent data between levels ... if $party is a SimSet, it should not be re-initialized when a new level is loaded ... if it is, then your setting it's values in the wrong place ...
The "$" part of the name states it is global, as long as it is not part of the scenegraph, then it will remain after the level has ended and a new one has been created ...
How ever, if the contents of this SimSet are scene graph objects such as Sprites, etc ... then you'll have a problem ...
I would suggest that during an 'load next level' function, that you go through all the objects and convert them into ScriptObjects ... and do the reverse when you call LoadLevel ... to recreate your level-scoped object equivalents ...
However, I wouldn't really suggest storing data such as 'party members', 'character stats', etc, etc ... in a scene graph object ...
If you have, let's say ... a Player object, which is a t2dStaticSprite ... then you should also create a PlayerData object which is a ScriptObject ... all your players dynamic persistent data should be stored in PlayerData ... and you should store PlayerData in the Party SimSet ... not Player ...
Does that help?