Game Development Community

Function running twice?

by NiN-NiN · in Torque 3D Beginner · 03/10/2014 (3:12 am) · 2 replies

I am really confused I have this working perfectly if i call menu() and action() in the console it only pics one and will move onto the next one once $weather variable goes up one.

The issue is as soon as I try to have a keyboard command run it there are issues it seems to run the next command as well so if $weather = 1; it runs that function then runs the next one like $weather = 2;

so i hear the audio for rain then cloud play but it's perfect in the console

I can't work it out this is the keybinds i have

moveMap.bind( keyboard, t, menu );
moveMap.bind( keyboard, y, action );


#1
03/10/2014 (3:45 am)
Bound functions are called on key press and release. The function is passed a single argument that is 1 if the event is a press, and 0 if it's a release.
#2
03/10/2014 (7:15 pm)
Thanks Daniel I didn't realise that it has options for on press and on release

for anyone who's looking this is what I did

function launchmenu(%val)
{
if(%val) {
menu();
}
}

You must use if(%val) to check for just the press so it runs once instead of on press and on release