I added a new common library to TSTK for actionMaps.
This common library adds two new (user) methods:

  • ActionMap::bindMulti( %this, %device, %action, %object, %callback );
  • ActionMap::unbindMulti( %this, %device, %action, %object, %callback );

The “bindMulti()” function allows you to bind the same input (key, button, etc.) to more than one callback. Typically, you can only bind one function (or object + method) to any specific input. However, in some cases it is useful to have the ability to bind the same input to more than one function (or object + method). For example. If you wanted to allow a key press to fire multiple weapons, you could simply use “bindMulti()” to bind the same key to each of the callbacks for each different weapon (see code sample below):

function firstWeapon::fire( %this, %val ) {
// ... more code
}
function secondWeapon::fireMe( %this, %val ) {
// ... more code
}
function thirdWeapon::fireMeToo( %this, %val ) {
// ... more code
}

// ... more code

moveMap.bindMulti( "Keyboard", "space", firstWeapon, "fire" );
moveMap.bindMulti( "Keyboard", "space", secondWeapon, "fireMe" );
moveMap.bindMulti( "Keyboard", "space", thirdWeapon, "fireMeToo" );

In the above example, three different weapons and their respective callbacks have been mapped to the same key (the spacebar).

I hope you find this useful.

Cheers,

edo

PS – I’m still working on getting a faster site. Sorry for the slowwwwness!

3 Responses to “Updated TSTK to rev 104”

  • raspes says:

    Hola gracias por tus aportes, creeme que no hay aporte que no trate de revisar y entender, aunque acepto que algunos si me han costado trabajo aprender, pero sinceramente lo que se de TGE es gracias a lo que has enseƱado, muchas gracias y ojala no dejes de seguir aportando tu conocimiento. Thanks for all

  • Hi, Congratulations to the site owner for this marvelous work you’ve done. It has lots of useful and interesting data.

  • JamesD says:

    Thanks for the useful info. It’s so interesting

Leave a Reply