Game Development Community

Save isn't working

by Tom Perry · in Torque Game Builder · 08/27/2007 (12:39 pm) · 11 replies

I am using the code below, taken from a working example in another thread:

function MakeValues()
{
   %obj = new ScriptObject(player);
   %obj.Something=2;
   %obj.somethingelse=4;
   player.save("game/data/something.cs");
}

No file is created however.

#1
08/27/2007 (12:55 pm)
Try placing in a full path to where you want to save the object.
#2
08/27/2007 (1:00 pm)
That is the full path, as in if I have this line:

exec("game/data/somthing.cs");

it will load the file.

This code doesn't work either:

function MakeValues()
{   
%obj = new ScriptObject(player);   
%obj.Something=2;   
%obj.somethingelse=4;   
player.save("./something.cs");
}
#3
08/27/2007 (1:36 pm)
Do you get any error messages in the console?

Also have you tried changing the last line to: %obj.save instead of player.save
#4
08/27/2007 (1:55 pm)
No errors, and %obj doesn't work either. Can anyone confirm that save works with their TGB? I haven't touched the source so it shouldn't make any difference.
#5
08/27/2007 (2:03 pm)
I actually went ahead and tried your example.

I got nothing.

I went ahead and tried a few different things and still got nothing.

What version of TGB are you using? I am using TGB 1.5.1.

I am going to keep trying a few things and see if I can figure out what's going on.
#6
08/27/2007 (3:25 pm)
The "About" box from the help menu says 1.5, though I'm sure I installed 1.5.1. It's one or the other. Thanks for looking into it, it's becoming a right pain :P
#7
09/02/2007 (3:19 pm)
exec("game/data/somthing.cs");

In this you have "somthing.cs" and in your other example you have "something.cs"

function MakeValues()
{   
%obj = new ScriptObject(player);   
%obj.Something=2;   
%obj.somethingelse=4;   
player.save("./something.cs");
}

Just a typo.
#8
09/02/2007 (3:24 pm)
O no sorry, that line:
exec("game/data/somthing.cs");

was just to demonstrate that that was the full path. The code I am testing is:

//-------------------------------------------------------------
// loadProfiles()
// This is will the profile data.
//-------------------------------------------------------------

function loadProfiles()
{
   exec("game/data/profileData.cs");
   if(!(isObject(profileData)))
   {
      echo("no data");
      new ScriptObject(profileData);
   }
}

//-------------------------------------------------------------
// saveProfiles()
// This saves the profileData to file
//-------------------------------------------------------------

function saveProfiles()
{
   if (isObject(profileData))
   {
      echo("data exisits :"@profileData.getID());
      profileData.save("./profileData.cs");
   }
}

I start the game up and call LoadProfiles() from the console (an warning message appears sayin no such file exists). I then call saveProfiles(). I then delete the profile data (profiledata.delete()) and call loadProfiles() again. If everything went to plan we should have a profiledata object, but we dont, no file exists and the console outputs "no data".
#9
09/26/2007 (3:37 pm)
I have the same problem here :(
#10
09/27/2007 (9:53 am)
Do to other things coming up I havn't looked into this any deeper. In otherwords I am stuck on this still as well. Anyone who has save working in TGB like to pitch in here it would be of great help! :D