function gameConnection::loadData(%this)
{
//set the path, we'll use an example for now
%path = "config/server/yourmodname/clientdata/" @ %this.bl_id @ ".txt";
//open a new file object for reading purposes
%f = new fileObject();
%f.openForRead(%path);
//while the file we have open is not at the end (eof = end of file), loop and run code
while(!%f.isEof())
{
%l = %f.readLine();
//Could use a better check method but this is fine for me
//This is to ignore the annotations the script object automatically throws into the file
if(strStr(%l,"BEGIN") >= 0 || strStr(%l,"END") >= 0)
//continue basically means, go back to the top and ignore everything below
continue;
//append to var
//method could cause problems with lots of data
%so = %so @ %l;
}
//so basically, we put every line into one variable
//but now we need to actually create the script object
//so we will use eval to do so
//pretty much saying, %nso = new scriptObject(){vars,etc};
eval("%nso = " @ %so);
//did the code we tried to eval actually create a script object?
if(isObject(%nso))
{
echo("Script object from file ==> " @ %nso @ ".");
//tag the client
//so now, %this.dataObject will be the script object
//we loaded from the file
%this.dataObject = %nso;
//return the script object
return %nso;
}
else
echo("Script object from file ==> failed to load.");
return -1;
}