Simple Digital Speedometer
by Quentin Headen · 04/04/2007 (3:47 pm) · 1 comments
First thing you want to do is to add the simple code. Open up whatever you use to code Torque Script, then type this in.
Now start the game, open up the GUI Editor in Torque, and add a text element. Change the profile to GuiBigTextProfile. After that go down to the variable field and type in the variable $myspeed. Apply the changes, save the gui, then open up the console and type in MySpeed(). Once you to this, the text element will show the speed value of your control object, and when you move the speed will update.
function MySpeed()
{
//This is the variable that you put the speed
$myspeed = getControlObjectSpeed();
//This schedule function will allow the function to loop every 1 millisecond, thus updating the
speed
schedule(1, 0, "MySpeed");
}Now start the game, open up the GUI Editor in Torque, and add a text element. Change the profile to GuiBigTextProfile. After that go down to the variable field and type in the variable $myspeed. Apply the changes, save the gui, then open up the console and type in MySpeed(). Once you to this, the text element will show the speed value of your control object, and when you move the speed will update.
About the author
Just your average programmer who tries to finish the projects he starts. :) I am currently focused on creating games with Torque engines. My website is http://phaseshiftsoftware.com

Zod