Using SimObject.save, but how do you load?
by Brandon James · in General Discussion · 03/07/2006 (8:30 am) · 3 replies
Hi All,
I'm trying to save some game data and I'd like to use the built in save feature of a ScriptObject. The data I'm saving is NOT part of the C++ code since I'm trying to do some rapid prototyping.
Here's what I do:
//--------------------------------------
%file = "/gameName/data.txt";
%foo = new ScriptObject();
%foo.bar = "aaa";
%foo.bally = "bbb";
%foo.save(%file);
%bax = exec(%file);
%bax.dump();
//---------------------------------------
Unfortunately, I get an error telling me that %bax has been given a value of 1 and that it isn't a valid object. Thus I cannot call dump on it. I look at it in the torsion debugger and also see that %bax is 1.
Here is the data that gets written to my file:
//--- OBJECT WRITE BEGIN
new ScriptObject() {
bar = "aaa";
bally = "bbb";
};
//--- OBJECT WRITE END
So it seems good on the save side. What am I doing wrong on the load?
Thanks for any help,
I'm trying to save some game data and I'd like to use the built in save feature of a ScriptObject. The data I'm saving is NOT part of the C++ code since I'm trying to do some rapid prototyping.
Here's what I do:
//--------------------------------------
%file = "/gameName/data.txt";
%foo = new ScriptObject();
%foo.bar = "aaa";
%foo.bally = "bbb";
%foo.save(%file);
%bax = exec(%file);
%bax.dump();
//---------------------------------------
Unfortunately, I get an error telling me that %bax has been given a value of 1 and that it isn't a valid object. Thus I cannot call dump on it. I look at it in the torsion debugger and also see that %bax is 1.
Here is the data that gets written to my file:
//--- OBJECT WRITE BEGIN
new ScriptObject() {
bar = "aaa";
bally = "bbb";
};
//--- OBJECT WRITE END
So it seems good on the save side. What am I doing wrong on the load?
Thanks for any help,
#2
Thanks for your help, this basically makes sence but now I'm confused about the scoping.
I thought that local variables started with % and globals started with $. Why does FRED work without either of these punctuation markers? What scope is FRED available in?
Thanks again
03/07/2006 (8:54 am)
I see. Thanks for your help, this basically makes sence but now I'm confused about the scoping.
I thought that local variables started with % and globals started with $. Why does FRED work without either of these punctuation markers? What scope is FRED available in?
Thanks again
Associate Anthony Rosenbaum
one thing you can do is name each script object to use it