Updated TSTK to rev 104
by Edward F. Maurina III · 05/09/2009 (1:41 am) · 4 comments
I've added a small bit of functionality to TSTK (Torque Script Tool Kit) which you may find useful. Specifically, I added some code to allow actionMap objects to bind the same key (or other input) to multiple functions and/or objects + methods.
Typically, you can bind only one function or object + method to a single key (or other input).
With the changes to TSTK, you can now accomplish what I tried to do above as follows:
Now, if the spacebar is pressed, both "doit()" and "doit2()" will be called.
If we wanted to bind objects + methods, we would do this:
Of course, the callbacks and functions can be anything you want them to be, and you can bind functions and objects + method simultaneously to the same input. Anything goes.
For an update of TSTK, just go to my download page and get it.
TSTK is now at rev 104.
I hope some folks find this useful.
PS - There is a reciprocal "ActionMap::unbindMulti()", but it currently does nothing. I'll put some unbind functionality in there eventually.
Typically, you can bind only one function or object + method to a single key (or other input).
moveMap.bind( "keyboard", "space", "doit" ); moveMap.bind( "keyboard", "space", "doit2" );In the above code, I tried binding the spacebar to two different functions, "doit()", and "doit2()". This won't work. Instead, the last binding (to "doit2()") will be the one that takes effect.
With the changes to TSTK, you can now accomplish what I tried to do above as follows:
moveMap.bindMulti( "keyboard", "space", "", "doit" ); moveMap.bindMulti( "keyboard", "space", "", "doit2" );
Now, if the spacebar is pressed, both "doit()" and "doit2()" will be called.
If we wanted to bind objects + methods, we would do this:
moveMap.bindMulti( "keyboard", "space", myObj, "aCallback" ); moveMap.bindMulti( "keyboard", "space", myOtherObj, "aCallback2" );In the above code, I've bound the spacebar to the callback "aCallback()" for object "myObj". I have also bound "aCallback2()" for object "myOtherObj" to the spacebar.
Of course, the callbacks and functions can be anything you want them to be, and you can bind functions and objects + method simultaneously to the same input. Anything goes.
For an update of TSTK, just go to my download page and get it.
TSTK is now at rev 104.
I hope some folks find this useful.
PS - There is a reciprocal "ActionMap::unbindMulti()", but it currently does nothing. I'll put some unbind functionality in there eventually.
About the author
#2
05/09/2009 (7:41 pm)
Hey thanks, Sincerely I have learned a lot with your teachings and examples, thanks for the update
#3
@Erick - Thanks. I hope to have more soon.
05/10/2009 (10:06 am)
@Ted - Sounds good send it off any time to tstk <at> roaminggamer <dot> com. I look forward it.@Erick - Thanks. I hope to have more soon.
#4
05/29/2009 (11:31 am)
Sent. 
Torque 3D Owner Ted Southard