Question: Restart TGB after script changes
by Turnstyle Studios · in Torque Game Builder · 04/25/2007 (11:45 am) · 7 replies
Hello,
I am doing some work with the Torque Game Builder and I was wondering how do I get it to reload my scripts after changes? I find that when I make a change to the script I have to stop and restart the engine for the changes to take effect. Any ideas how I could skip the restart phase?
Thanks a lot in advance.
I am doing some work with the Torque Game Builder and I was wondering how do I get it to reload my scripts after changes? I find that when I make a change to the script I have to stop and restart the engine for the changes to take effect. Any ideas how I could skip the restart phase?
Thanks a lot in advance.
#2
04/25/2007 (3:17 pm)
Thanks!
#3
but generically speaking, I usually have something like an "exec.cs" that has all my exec's in it ... so I don't have to reload the main.cs or the game.cs every time ... and I can actually just run exec("~/exec.cs"); ... and update my scripts (helpful for doing live updates of things while test playing without having to restart the test ;p)
04/25/2007 (6:28 pm)
Turnstyle, alternatively, you can just run the command exec("~/main.cs"); ... which will re-exec the main.cs for you... reloading all your scripts ...but generically speaking, I usually have something like an "exec.cs" that has all my exec's in it ... so I don't have to reload the main.cs or the game.cs every time ... and I can actually just run exec("~/exec.cs"); ... and update my scripts (helpful for doing live updates of things while test playing without having to restart the test ;p)
#4
you just put the command line in and all the scripts get updated?
sweet!
04/26/2007 (7:54 am)
So you can do it without even leaving the runtime of the game?you just put the command line in and all the scripts get updated?
sweet!
#5
04/26/2007 (5:36 pm)
Edgar ... yeah, thats the general idea ... though, it doesn't always work out the way you'd expect ... if it doesn't refresh all your functions ... just simple hit escape, go back to level builder and hit f5 .... some things can be updated at run-time, somethings can't ... not really sure where the breaking point between the two is ... I just figure ... if it doesn't work the way I thought it should, I go back ... ;)
#6
If you don't use the above if-statement you will run into errors within the editor. I found that every time I re-simulated the game from the editor (with my all of my script files getting exec()'d in game.cs), my datablock entries were getting duplicates, triplicates, etc. in the editor's drop down menus. In short, funky things start happening.
Be careful whenever you name an object upon creation in script (particularly datablocks). Those can come and bite you. That's the only issue I've really bumped up against with this stuff...
04/26/2007 (7:08 pm)
You need to be careful, however. If you've ever defined a Datablock or object in script like this:if(!isObject(playerData)) datablock t2dSceneObjectDatablock(playerData){...};then they will not be updated when you run exec() (or re-simulate your game). In those instances you have to restart the editor (alternatively you could exec() any datablock scripts in main.cs and then all functionality scripts in game.cs).If you don't use the above if-statement you will run into errors within the editor. I found that every time I re-simulated the game from the editor (with my all of my script files getting exec()'d in game.cs), my datablock entries were getting duplicates, triplicates, etc. in the editor's drop down menus. In short, funky things start happening.
Be careful whenever you name an object upon creation in script (particularly datablocks). Those can come and bite you. That's the only issue I've really bumped up against with this stuff...
#7
:)
04/26/2007 (8:09 pm)
Heh, all my checks do this:if(isObject(dataBlock)) dataBlock.delete();
new datablock(dataBlock)
{
};:)
Torque Owner Edgar Doiron