Debug Panel Toggle Key
by Steve1982 · in Torque Game Builder · 03/02/2009 (4:16 pm) · 6 replies
I'm trying to setup the F1 key to toggle the debug panel off and on. Here is my code:
function BallClass::onLevelLoaded(%this, %scenegraph)
{
%this.setSpeed();
%this.setLinearVelocityX(%this.speed);
%this.setLinearVelocityY(%this.speed);
GlobalActionMap.bind(keyboard, "F1", toggleDebugPanel);
}
function toggleDebugPanel(%this, %scenegraph )
{
if %scenegraph.getDebug == true
%scenegraph.setDebugOff(0); <==parse error
else
%scenegraph.setDebugOn(0);
}
I'm using Torsion and it gives a parse error. Any help is always appreciated.
function BallClass::onLevelLoaded(%this, %scenegraph)
{
%this.setSpeed();
%this.setLinearVelocityX(%this.speed);
%this.setLinearVelocityY(%this.speed);
GlobalActionMap.bind(keyboard, "F1", toggleDebugPanel);
}
function toggleDebugPanel(%this, %scenegraph )
{
if %scenegraph.getDebug == true
%scenegraph.setDebugOff(0); <==parse error
else
%scenegraph.setDebugOn(0);
}
I'm using Torsion and it gives a parse error. Any help is always appreciated.
#2
03/02/2009 (7:46 pm)
#3
03/02/2009 (9:32 pm)
Your if statements need to be setup with Parenthesis and curly brackets like thisif ( %blaaahh == %blahblam)
{
doSomethingCool();
}
else
{
notCool();
}
#4
function BallClass::onLevelLoaded(%this, %scenegraph)
{
%this.setSpeed();
%this.setLinearVelocityX(%this.speed);
%this.setLinearVelocityY(%this.speed);
GlobalActionMap.bind(keyboard, "F1", toggleDebugPanel(%scenegraph));
}
function toggleDebugPanel(%scenegraph)
{
if (%scenegraph.getDebug == true)
{
%scenegraph.setDebugOff(0);
}
else
{
%scenegraph.setDebugOn(0);
}
}
Thanks again for your help.
03/03/2009 (4:06 pm)
I made the changes you suggested and it compiles now but I'm not getting the results I expected. When the program runs, the debug banner is always displayed. Pressing F1 has no effect. My code is:function BallClass::onLevelLoaded(%this, %scenegraph)
{
%this.setSpeed();
%this.setLinearVelocityX(%this.speed);
%this.setLinearVelocityY(%this.speed);
GlobalActionMap.bind(keyboard, "F1", toggleDebugPanel(%scenegraph));
}
function toggleDebugPanel(%scenegraph)
{
if (%scenegraph.getDebug == true)
{
%scenegraph.setDebugOff(0);
}
else
{
%scenegraph.setDebugOn(0);
}
}
Thanks again for your help.
#5
For future reference, you should put your code inside [code ][/code ] tags to make them easier to read (remove the spaces in the tags to get them to work).
Edit: How odd, weird line breaks where there shouldn't be!
03/03/2009 (4:48 pm)
Steve, try this:GlobalActionMap.bindCmd(keyboard, "F1", "toggleDebugPanel(" @ %scenegraph @ ");", "");function toggleDebugPanel(%sceneGraph)
{
if (!%sceneGraph.getDebugOn(0))
{
%sceneGraph.setDebugOn(0);
}
else
{
%sceneGraph.setDebugOff(0);
}
}For future reference, you should put your code inside [code ][/code ] tags to make them easier to read (remove the spaces in the tags to get them to work).
Edit: How odd, weird line breaks where there shouldn't be!
#6
03/03/2009 (5:13 pm)
That worked perfectly. Thank you Phillip.
Torque 3D Owner Jason Ravencroft