>> Advanced script error re"> Exec a file | Torque Game Builder | Forums | Community | GarageGames.com

Game Development Community

Exec a file

by Igor Kuryatnikov · in Torque Game Builder · 11/15/2006 (3:03 am) · 11 replies

Please tell me, how can I exec compiled *.dso file without original *.cs

There is an error, while I try to call "exec("save/test.cs.dso");"
In log:
Compiling save/test.cs.dso...
save/test.cs.dso Line: 1 - parse error
>>> Advanced script error report.  Line 1.
>>> Some error context, with ## on sides of error halt:
##
>>> Error report complete.

if I just pass "save/test.cs" the engine find nothing.
In log:
Compiling save/test.cs...
exec: invalid script file save/test.cs.

Is this true what I've must supply all *.cs files in order to exec compiled version of them?
Thanks.

#1
11/15/2006 (4:21 am)
You don't need to worry about it, just leave your exec's as

exec("save/test.cs");

TGB will automatically use "save/test.cs.dso" if "save/test.cs" does not exist. This means when you want to ship your game, you can delete all the "cs" files and just leave the "dso" and TGB will use those without any need for code changes.
#2
11/15/2006 (4:56 am)
Thank you for your answer.
That should be, but...

This is what I do: (just a test)
new SimObject(savetest)
   {
      fileda = "blahblahblah";
      filedb = "blahblahblah";
      filedc = "blahblahblah";
   };
   
   savetest.save("save/test.cs");
   savetest.delete();
   
   compile("save/test.cs");
   fileDelete("save/test.cs");
   
   exec("save/test.cs");

and output:

...
Executing game/scenario/db.cs.
Executing game/scenario/game.cs.[b]
Compiling save/test.cs...
exec: invalid script file save/test.cs.[/b]
Executing game/player/data/walk.cs.
...

File definitely exist, I mean "save/test.cs.dso".
What is wrong?
#3
11/15/2006 (11:21 am)
Try

exec("~/save/test.cs");
#4
11/15/2006 (10:54 pm)
Ok, I tried exec("~/save/test.cs");
here is the log:

Loading compiled script game/scenario/db.cs.
Loading compiled script game/scenario/game.cs.
Compiling save/test.cs...
Missing file: game/save/test.cs!
Loading compiled script game/player/data/walk.cs.

and even with .dso extension ( exec("~/save/test.cs.dso"); )
Loading compiled script game/scenario/db.cs.
Loading compiled script game/scenario/game.cs.
Compiling save/test.cs...
Missing file: game/save/test.cs.dso!
Loading compiled script game/player/data/walk.cs.

The file test.cs.dso exist, I can see it in explorer.

Any ideas?
#5
11/15/2006 (11:15 pm)
These threads always end with someone saying "Have you tried expandFileName()?"

So maybe that someone'll be me ;)

There have been a bunch recently.
#6
11/16/2006 (12:19 am)
Nope, you aren't ) I tried expandFileName(), and nothing has changed:

Loading compiled script game/scenario/db.cs.
Loading compiled script game/scenario/game.cs.
Compiling save/test.cs...
Missing file: game/save/test.cs!
Loading compiled script game/player/data/walk.cs.

This should be a bug...

Create simple an empty project and add this to startGame(%level):
new SimObject(savetest)
   {
      fileda = "blahblahblah";
      filedb = "blahblahblah";
      filedc = "blahblahblah";
   };
   
   savetest.save("save/test.cs"); // even with '~/' in the path
   savetest.delete();
   
   compile("save/test.cs");
   fileDelete("save/test.cs");
   
   exec("save/test.cs");
and you will see...

Any ideas?
#7
11/16/2006 (1:36 am)
It is my guess the file is not being saved/compiled/exec'd all from the same place. If you remove the "fileDelete" command, does it work?
#8
11/16/2006 (2:19 am)
Okay, this code is working fine:

new SimObject(savetest)
   {
      fileda = "blahblahblah";
      filedb = "blahblahblah";
      filedc = "blahblahblah";
   };
   
   savetest.save("save/test.cs");
   savetest.delete();
   
   compile("save/test.cs");
   //fileDelete("save/test.cs");
   
   exec("save/test.cs");
   
   if(isObject(savetest))
   {
      savetest.dump();
      savetest.delete();
   }

and output:

...
Loading compiled script game/scenario/db.cs.
Loading compiled script game/scenario/game.cs.
Compiling save/test.cs...
Loading compiled script save/test.cs.
Member Fields:
  canSaveDynamicFields = "1"
Tagged Fields:
  fileda = "blahblahblah"
  filedb = "blahblahblah"
  filedc = "blahblahblah"
Methods:
  delete() - obj.delete()
...
 and so on...
#9
11/16/2006 (2:55 am)
If I do not delete *.cs file this ain't be good way to save dynamic game data...
Is there anybody who load the *.dso files without source? How is shipped games are working?
#10
11/16/2006 (11:07 pm)
The problem is present yet. Any ideas?
#11
11/21/2006 (11:50 pm)
SetModPaths (getModPaths()); solved the problem. After file cache refreshed everything is ok.