Game Development Community

Hook into GuiCrossHairHud

by gamer · in Torque Game Engine · 04/03/2006 (5:49 pm) · 6 replies

Hi,
in the fps, I want to be able to popup a hud on the side that displays some info when the aiplayer enters my crosshair. how can this be done? I know that GuiCrossHairHud displays a small damage bar when someone enters the crosshair, but I can't find an easy way to make a callback function and pass it to GuiCrossHairHud.
any ideas?
thanks for the help

#1
04/03/2006 (6:34 pm)
The function you seek is
Con::executef(this,2,"onFunctionName",scriptThis());

placing it in the onRender would have it callback A LOT so where it is called is important
#2
04/03/2006 (6:45 pm)
Excuse my ignorance, does this do the following?
when FunctionName() is called, then scriptThis() is called.
is this right?
thanks
#3
04/03/2006 (7:31 pm)
It would callback to GuiCrossHairHud::functionName(%this) {}
#4
04/04/2006 (11:07 am)
Ok I tried a variant Con::executef(1,"scriptThis()"); in GuiCrossHairHud, but at runtime it says scripThis() command not found. I defined
function scriptThis(){
echo("hi");
}
what am I missing?
thanks
#5
04/04/2006 (11:30 am)
I also tried
Con::executef(this,2,onRender,"scriptThis()"); in GuiCrossHairHud.cc,
at runtime it gives this error:
Con::execute - 0 has no namespace: onRender,
what does this mean?
#6
04/04/2006 (11:55 am)
ScriptThis() is Method of SceneObject that returns the script representation of that object so you can access it in script.

Anothony's example is correct except for a small oversight. He forgot the on in the script function:

Con::executef( this, 2, "onFunctionName", scriptThis() );

would call this is script:

GuiCrossHairHud::onFunctionName( %this ) {}