Game Development Community

TorqueX has a console

by Matthew Shapiro · in Torque X 2D · 04/06/2008 (7:08 am) · 14 replies

Wow so did anyone else realize that TX has a debugging console or am I just slow?

If you hit ~ or press in the left analog stick on the 360 controller a console appears. You can use page up/page down to scroll (or up or down on the left analog stick), get properties by object (i.e. enter "playerShipTemplate.Position" to get the template's position), and you can even set properties (i.e. "playerShipTemplate.Rotation = 50").

Looking at the engine code you can also do the same with classes, so you can do "CameraManager.Instance.Active" and it retrieves that property. Very cool

Just thought I would share as I know I can make use of this rather than constantly using breakpoints to find out some of this stuff.

#1
04/06/2008 (7:29 am)
To be honest, I didn't know that :)
#2
04/06/2008 (7:51 am)
Guess it pays to randomly press buttons :D

It also looks like you can dump the console to a file, which can make debugging that much easier.

It looks like to do this you set the ConsoleGUI.Instance.ConsoleDumpFile property to the name of the file you want it to create (warning: it looks like if a file exists by that name it will delete it) then set ConsoleGUI.Instance.DumpToFile = true.

Though after looking at the dump file it isn't formatted at all (like not even one command one one line). You'd probably have to update the dump code to make it usable and readable.
#3
04/06/2008 (9:14 am)
Doesn't work for me for some reason.

I was trying with the StarterGame2.0 2D and TankBuster (all using TorqueX 2.0)

Is there anything that I have to do?
#4
04/06/2008 (9:20 am)
Hrm nope. My project is based off of StarterGame2.0 2D and it worked, as did it in the TankBuster demo.

I'm not sure if it will make a difference but do you have Pro or free (I have Pro).

*edit* Also in your code, can you access the ConsoleGUI singleton?
#5
04/06/2008 (9:47 am)
How would I access the ConsoleGUI singleton? I have the CC version of Torque X. The only difference is that the CC version doesn't have Torque X source code so I don't think thats the problem.
#6
04/06/2008 (10:12 am)
Nevermind, didn't realize ConsoleGUI class is marked as internal. Can you use the function TorqueConsole.Warn() ?

The only thing I can think of at this point is that non-Pro versions (versions without the TX engine source) do not have it due to the #if !XBOX directives in the code, but it looks like those are only used for parsing and allowing input into the console (I don't see any reason why you couldn't look at the console on the 360).

Only GG could confirm that though as I don't know how the non-pro version is built.
#7
04/06/2008 (11:07 am)
Perhaps the bindings allowing access to the console are only in the debug builds?

I don't know if non-pro copies come with debug and release builds or just release builds, but try switching to debug if you can. You may need to remove the dll references and point them to another location, as project references aren't per-configuration unfortunately.
#8
04/06/2008 (11:33 am)
I can use TorqueConsole.Warn().

So what should I do now that I can access the console?
#9
04/06/2008 (12:25 pm)
There's also a profiler:

F1 to toggle
F2 to start profiling

Surround the code block you want to profile with:

Profiler.Instance.StartBlock("MyClass.MyMethod");

// my code

Profiler.Instance.EndBlock("MyClass.MyMethod");

For the Console, besides ~, the left thumb button on the gamepad will toggle it.

You should be able to use:

TorqueConsole.Echo("My message");
TorqueConsole.Echo("My message {0}", myVariable);
  
TorqueConsole.Warn("My message");
TorqueConsole.Warn("My message {0}", myVariable);
 
TorqueConsole.Error("My message");
TorqueConsole.Error("My message {0}", myVariable);
#10
04/06/2008 (1:15 pm)
Hrm I was wondering how to use the profiler. Thanks.
#11
04/06/2008 (6:33 pm)
I created a project from the starter template. I didn't make any changes; just compiled it. Typing ~ did not access a console. There must be some magic incantation I'm missing.
#12
04/06/2008 (6:59 pm)
@Thomas

The TorqueConsole and Profiler are only enabled in debug mode (I think). If you are using binaries, it's probably the release version so it's not enabled. If you have Pro, ensure that

TORQUE_PROFILE;TORQUE_CONSOLE

are defined when building the torque engine project.
#13
04/06/2008 (8:38 pm)
I'm not using Pro. That must be it.
#14
04/06/2008 (9:12 pm)
Me neither :(