TGB debugging
by Thomas Wrather · in Torsion · 03/07/2007 (6:59 pm) · 23 replies
I'm trying out the Torsion demo with TGB and have a question about the debugger behavior. I'm not sure if I've incorrectly created my Torsion project, or not.
I made a TGB project, MyTestGame, using the TGB Level Editor. Then I created a Torsion project containing the MyTestName directory tree.
When I start the debugger in Torsion, it starts the TGB Level Editor. Then from the TGB Level Editor I have to run my game. Is this the way it is supposed to be? I was expecting my game to be started directly from Torsion.
If I've set up my Torsion project incorrectly, maybe someone could post a .torsion file for one of the demo projects included with TGB for me to reference.
Thanks.
I made a TGB project, MyTestGame, using the TGB Level Editor. Then I created a Torsion project containing the MyTestName directory tree.
When I start the debugger in Torsion, it starts the TGB Level Editor. Then from the TGB Level Editor I have to run my game. Is this the way it is supposed to be? I was expecting my game to be started directly from Torsion.
If I've set up my Torsion project incorrectly, maybe someone could post a .torsion file for one of the demo projects included with TGB for me to reference.
Thanks.
#2
I tried the -notools option, but there must be something else that needs to added/changed to use that option. I used the provided ExampleMyFishDemo TGB project to test the -notools option. -notools causes a blank TGB window to open, and nothing else happens. Without -notools, I got the TGB Level Editor as expected.
Here's my .torsion file:
ExampleMyFishDemo
..\
main.cs
ExampleMyFishDemo
cs; gui
Default
..\TGB.exe
-notools -game ExampleMyFishDemo
false
true
true
false
TGB
HEAD
true
03/10/2007 (8:28 am)
Thanks for the response. I wasn't expecting anyone to be home until well after GDC. :)I tried the -notools option, but there must be something else that needs to added/changed to use that option. I used the provided ExampleMyFishDemo TGB project to test the -notools option. -notools causes a blank TGB window to open, and nothing else happens. Without -notools, I got the TGB Level Editor as expected.
Here's my .torsion file:
#3
From Torsion, when I "start without debugging" it just launches the level editor, rather than also running the game as the Torsion setup doc mentions.
Furthermore, I tried to setup some breakpoints and a watch variable in the Fish Game, but when I "start" (F5) from Torsion, nothing seems to happen. My Windows task manager says that this launches a TGB.exe process, but neither the level builder or game launches or appears appears in the task bar. I guess I don't see how you actually debug anything.
Any guesses as to what I'm doing wrong?
--Sirlin
03/24/2007 (2:13 am)
I'm in a similar boat here, and I'm a designer not a programmer, so I'm pretty lost.From Torsion, when I "start without debugging" it just launches the level editor, rather than also running the game as the Torsion setup doc mentions.
Furthermore, I tried to setup some breakpoints and a watch variable in the Fish Game, but when I "start" (F5) from Torsion, nothing seems to happen. My Windows task manager says that this launches a TGB.exe process, but neither the level builder or game launches or appears appears in the task bar. I guess I don't see how you actually debug anything.
Any guesses as to what I'm doing wrong?
--Sirlin
#4
In the same folder as the TGB.exe you're running, should be a main.cs file. Have a look at the head of the file and you'll find an option to totally disable the level editor "$runwitheditors" although, during development you're probably better off using the -notools switch Tom mentioned above.
In addition to this though, theres one further step. If you go into your game folder, eg if your project is called FishDemo. Then find your TGB.exe and go into the "FishDemo" folder. You should see several folders such as data, gamescripts, gui, managed, and a file called main.cs
This main.cs file is loaded at started by the main.cs file one folder up (eg the one in the same dir as TGB.exe). If you open this file, the top function is called "initializeProject" which is setup as follows
If the $runwitheditors is false, if you have set it manually or via the -notools switch then the level editors will not be loaded. Thus the last line "startgame($levelEditor::LastLevel[$currentProject]);" will be incorrect as the $levelEditor variable hasn't been set.
Simply change the startGame line for whatever level you want to load first. EG
It may be useful to also change the game.cs file in gameScripts folder, in the "startGame" function look for
and change it to
Then you'll get a console indication of the problem if your parameter to start game isn't valid.
03/24/2007 (6:10 am)
@Thomas: In the same folder as the TGB.exe you're running, should be a main.cs file. Have a look at the head of the file and you'll find an option to totally disable the level editor "$runwitheditors" although, during development you're probably better off using the -notools switch Tom mentioned above.
In addition to this though, theres one further step. If you go into your game folder, eg if your project is called FishDemo. Then find your TGB.exe and go into the "FishDemo" folder. You should see several folders such as data, gamescripts, gui, managed, and a file called main.cs
This main.cs file is loaded at started by the main.cs file one folder up (eg the one in the same dir as TGB.exe). If you open this file, the top function is called "initializeProject" which is setup as follows
//---------------------------------------------------------------------------------------------
// initializeProject
// Perform game initialization here.
//---------------------------------------------------------------------------------------------
function initializeProject()
{
// Load up the in game gui.
exec("~/gui/mainScreen.gui");
// Exec game scripts.
exec("./gameScripts/game.cs");
// Remove the following four lines if you would like to start the game without running the
// level builder.
if ($runWithEditors)
{
toggleLevelEditor();
return;
}
// This is where the game starts. Right now, we are just starting the first level. You will
// want to expand this to load up a splash screen followed by a main menu depending on the
// specific needs of your game. Most likely, a menu button will start the actual game, which
// is where startGame should be called from.
startGame($levelEditor::LastLevel[$currentProject]);
}If the $runwitheditors is false, if you have set it manually or via the -notools switch then the level editors will not be loaded. Thus the last line "startgame($levelEditor::LastLevel[$currentProject]);" will be incorrect as the $levelEditor variable hasn't been set.
Simply change the startGame line for whatever level you want to load first. EG
startGame( "FishDemo/data/levels/Level2.t2d" );
It may be useful to also change the game.cs file in gameScripts folder, in the "startGame" function look for
moveMap.push();
if( isFile( %level ) || isFile( %level @ ".dso"))
sceneWindow2D.loadLevel(%level);and change it to
moveMap.push();
if( isFile( %level ) || isFile( %level @ ".dso"))
sceneWindow2D.loadLevel(%level);
else
error( "Invalid Level Filename -" SPC %level );Then you'll get a console indication of the problem if your parameter to start game isn't valid.
#5
Thanks for the detailed reply. Torsion now behaves as I expected.
Only 7 days left on my free trial. Now I can register Torsion with any seconds thoughts. :)
David,
In your Profile Configuration, are you specifying the "-game" option? Also, did you set the base directory one level above the Fish game directory (tricky because there are main.cs files at both directory levels)?
03/24/2007 (2:06 pm)
Gary,Thanks for the detailed reply. Torsion now behaves as I expected.
Only 7 days left on my free trial. Now I can register Torsion with any seconds thoughts. :)
David,
In your Profile Configuration, are you specifying the "-game" option? Also, did you set the base directory one level above the Fish game directory (tricky because there are main.cs files at both directory levels)?
#6
03/24/2007 (2:41 pm)
The torsion help file says to set the project config file to use the debug executable. I can't find a debug executable. The Torsion project's config has this executable listed as TGB_Debug.exe which does not appear in the filepath that said config points to.
#7
As far as getting debugging and breakpoints to work, I'm still at a loss. Thomas, my base directory is correctly set one level above the FishGame directory. The -game option just launches a black window for me though. Whether I use -game or not, "start" (F5) still doesn't actually launch any real app, just a TGB.exe process in my task manager.
Is there some TGB_DEBUG.exe I'm supposed to pointing to? That's mentioned in the Torsion setup doc, but I don't see that exe anywhere.
--David
03/24/2007 (2:45 pm)
I used Gary's helpful explanation to create one config that launches the game directly (using -notools and his modification to the startgame() line) and another config that launches the editor. Great.As far as getting debugging and breakpoints to work, I'm still at a loss. Thomas, my base directory is correctly set one level above the FishGame directory. The -game option just launches a black window for me though. Whether I use -game or not, "start" (F5) still doesn't actually launch any real app, just a TGB.exe process in my task manager.
Is there some TGB_DEBUG.exe I'm supposed to pointing to? That's mentioned in the Torsion setup doc, but I don't see that exe anywhere.
--David
#8
I too saw the mention of TGB_DEBUG.exe, but I have had no problem using the standard TGB.exe. I could build a TGB_DEBUG.exe, but so far all the bugs have been in my script code rather than in the TGB engine.
I created a FishDemo project and was able to set and hit breakpoints. Here is my FishDemo.torsion file:
FishDemo
..\
main.cs
FishDemo
cs; gui
Default
..\TGB.exe
-game FishDemo
false
true
true
false
TGB
HEAD
true
03/24/2007 (4:49 pm)
David,I too saw the mention of TGB_DEBUG.exe, but I have had no problem using the standard TGB.exe. I could build a TGB_DEBUG.exe, but so far all the bugs have been in my script code rather than in the TGB engine.
I created a FishDemo project and was able to set and hit breakpoints. Here is my FishDemo.torsion file:
#9
Can someone describe what is *supposed* to happen after you hit F5, so I know what to even expect here. Also, just wanted to say that the help is greatly appreciated.
Anyway, here is my torsion file, which looks very similar to Thomas W's:
MyFishGame
..\
main.cs
MyFishGame
cs; gui
LaunchGameDirectly
..\TGB.exe
-game MyFishGame -notools
false
true
true
false
LaunchTool
..\TGB.exe
false
true
true
false
TGB
HEAD
true
--David
03/24/2007 (7:53 pm)
There's a Thomas W and a W Thomas in this thread, lol.Can someone describe what is *supposed* to happen after you hit F5, so I know what to even expect here. Also, just wanted to say that the help is greatly appreciated.
Anyway, here is my torsion file, which looks very similar to Thomas W's:
--David
#10
Loading compiled script FishDemo/data/levels/Level9.t2d.
Compiling tools/editorClasses/scripts/RSSNews/RSSCache.cs...
Loading compiled script tools/editorClasses/scripts/RSSNews/RSSCache.cs.
Executing FishDemo/gameScripts/game.cs.
Once the breakpoint is hit you can step though the code, or continue. As you step though the code, the yellow arrow moves to indicate the point of execution.
03/25/2007 (6:45 am)
Open FishDemo/gameScripts/game.cs. Right click on a line in the startGame function and select 'Insert Breakpoint.' A red dot appears beside the line. Hit F5. FishDemo runs up until it hits the breakpoint. The red dot now has a yellow arrow inside to indicate that execution has stopped at this point. Note that at this point the game screen is still blank. The last few lines in the output window are:Loading compiled script FishDemo/data/levels/Level9.t2d.
Compiling tools/editorClasses/scripts/RSSNews/RSSCache.cs...
Loading compiled script tools/editorClasses/scripts/RSSNews/RSSCache.cs.
Executing FishDemo/gameScripts/game.cs.
Once the breakpoint is hit you can step though the code, or continue. As you step though the code, the yellow arrow moves to indicate the point of execution.
#11
Prueba
main.cs
cs; gui
PruebaConf
..\TGB.exe
-game prueba
false
true
true
false
TGB
HEAD
true
HexDUmp
04/29/2007 (10:11 am)
I don't know if I'm dumb or something but I can't make torsion debug my scripts :(. I have read all the thread and setup it serveral times without luck, here it is my torision conf file:HexDUmp
#12
Prueba
main.cs
cs; gui
PruebaConf
..\TGB.exe
-game prueba
false
true
true
false
TGB
HEAD
true
04/29/2007 (10:12 am)
Sorry, I inserted a z in the wrong place when pasting... here is the correct Options file:
#13
05/03/2007 (8:26 pm)
Any idea how to disable the tools in TGB 1.5 beta? It doesn't have a 'runwithtools' variable that I can find at all and -notools isn't even an option.
#14
05/04/2007 (12:14 am)
I think the exe is differente, so I would say, point to the runtime exe, not the editor exe.
#15
05/04/2007 (7:34 am)
The only exe that is in the TGB 1.5 installed folders is the editor exe.
#16
Instead of using TorqueGameBuilder.exe use the Game exe directly and pass it the project to run.
Set the Executable var to (tgbrootpath)/tgb/gameData/T2DProject/TGBGame.exe
Then set the Arguments parameter to -project "your full project path"
You have to enclose the path in " in case i contains spaces etc.
You will be able to debug it just fine (although precompile is broken at the moment because of some changes to TGB that I am sure is giving Tom grey hair)
05/04/2007 (10:12 am)
@Jonathon: Instead of using TorqueGameBuilder.exe use the Game exe directly and pass it the project to run.
Set the Executable var to (tgbrootpath)/tgb/gameData/T2DProject/TGBGame.exe
Then set the Arguments parameter to -project "your full project path"
You have to enclose the path in " in case i contains spaces etc.
You will be able to debug it just fine (although precompile is broken at the moment because of some changes to TGB that I am sure is giving Tom grey hair)
#17
05/04/2007 (10:59 am)
@Neo - Like i need more grey hair. :)
#19
thisis what happens... whenever i hit Ctrl+F5, the TGB exe starts, but somehow, it doesnt show a damn thing! (you see it runnin at full power at the task manager, but it shows nothing!)...
this is the config of the torsion file
this is what i have in the MAIN.CS file
and this is what i have in the GAME.CS file
so, as you can see, i've got it setup the way its meant to be, but, somehow it just DOESNT start the level nor shit... so, anyone can shed some light here?, cuz, im pretty darn lost here...
thank you very much in advance.
EDIT:
nevermind... i found a way to debug and get the game runnin from Torsion:
all i had to do, was to change the game folder to the root Torque folder (./Game), so i ended up using the main MAIN.CS file (the one from the editor and not the one from the particular project) and using the main TGB exe... now that i think about it, its pretty much logical... but oh well...
problem with that method is that when i wanna try only one game, it will compile EVERY demo i have on that directory... so it might take a lil while to compile and run... so i guess ill have to setup another Torque folder where i can place the sole project and try makin any mods from there.
06/19/2007 (10:47 pm)
Ok... im pretty darn lost here, and would like someone to help me here...thisis what happens... whenever i hit Ctrl+F5, the TGB exe starts, but somehow, it doesnt show a damn thing! (you see it runnin at full power at the task manager, but it shows nothing!)...
this is the config of the torsion file
<TorsionProject> <Name>Kanastos</Name> <WorkingDir/> <EntryScript>main.cs</EntryScript> <Mods/> <ScannerExts>cs; gui</ScannerExts> <Configs> <Config> <Name>Kanastos</Name> <Executable>..\TGB.exe</Executable> <Arguments>-game Kanastos</Arguments> <HasExports>false</HasExports> <Precompile>true</Precompile> <InjectDebugger>true</InjectDebugger> <UseSetModPaths>false</UseSetModPaths> </Config> </Configs> <SearchURL/> <SearchProduct>TGB</SearchProduct> <SearchVersion>HEAD</SearchVersion> <ExecModifiedScripts>true</ExecModifiedScripts> </TorsionProject>
this is what i have in the MAIN.CS file
function initializeProject()
{
// Load up the in game gui.
exec("~/gui/mainScreen.gui");
// Exec game scripts.
exec("./gameScripts/game.cs");
exec("./gameScripts/player.cs");
exec("./gameScripts/enemy.cs");
exec("./gameScripts/playerMissile.cs");
exec("./gameScripts/enemyMissile.cs");
startGame("Kanastos/data/levels/nivel_1.t2d");
}and this is what i have in the GAME.CS file
function startGame(%level)
{
// Set The GUI.
Canvas.setContent(mainScreenGui);
Canvas.setCursor(DefaultCursor);
moveMap.push();
if( isFile( %level ) || isFile( %level @ ".dso"))
{
sceneWindow2D.loadLevel(%level);
}
else
{
error( "Invalid Level Filename -" SPC %level );
}
}so, as you can see, i've got it setup the way its meant to be, but, somehow it just DOESNT start the level nor shit... so, anyone can shed some light here?, cuz, im pretty darn lost here...
thank you very much in advance.
EDIT:
nevermind... i found a way to debug and get the game runnin from Torsion:
all i had to do, was to change the game folder to the root Torque folder (./Game), so i ended up using the main MAIN.CS file (the one from the editor and not the one from the particular project) and using the main TGB exe... now that i think about it, its pretty much logical... but oh well...
problem with that method is that when i wanna try only one game, it will compile EVERY demo i have on that directory... so it might take a lil while to compile and run... so i guess ill have to setup another Torque folder where i can place the sole project and try makin any mods from there.
#20
TGB.exe has to execute from the main game folder where main.cs and your game specific folder reside. If you change the "Base Directory" setting to not include your game folder (i assume this is Kanastos)... it should start working for you.
06/20/2007 (10:53 am)
@Ehrlichmann - Seems like your Torsion project file is in your game mod directory and not in the main game folder itself and your base directory is not set right. This is a common mistake. TGB.exe has to execute from the main game folder where main.cs and your game specific folder reside. If you change the "Base Directory" setting to not include your game folder (i assume this is Kanastos)... it should start working for you.
Associate Tom Spilman
Sickhead Games