Why is this code executing twice?
by Steve Howson · in Torque Game Engine · 09/08/2005 (7:22 pm) · 4 replies
Hi all.
Using some help I got in the Discussion forum, I'm playing around with the scripts to help me learn Torque (just recently purchased it).
I have the following code in my default.bind.cs:
It's inserted in where the other move keys are (a, d, w, s, etc...).
When i load it up and hit the b key, it displays 'Build function activated.' in the console, but displays it one line right under the other.
I don't yet know enough about Torque to figure out why it's executing twice, so if someone could help shed some light on this I'd appreciate it! :)
Thanks a lot!
Steve
Using some help I got in the Discussion forum, I'm playing around with the scripts to help me learn Torque (just recently purchased it).
I have the following code in my default.bind.cs:
function build(%val)
{
echo("Build function activated.");
}
moveMap.bind( keyboard, b, build );It's inserted in where the other move keys are (a, d, w, s, etc...).
When i load it up and hit the b key, it displays 'Build function activated.' in the console, but displays it one line right under the other.
I don't yet know enough about Torque to figure out why it's executing twice, so if someone could help shed some light on this I'd appreciate it! :)
Thanks a lot!
Steve
Torque Owner Brett Fattori
function build(%val) { if (%val) echo("Build function activated."); } moveMap.bind(keyboard, b, build);That should fix you right up. If instead you want it to trigger on the break, change it to "if (!%val)"
- Brett