This short tutorial explains how to get some custom functions you defined in a script or in the engine code (e.g. toggle Night Vision Goggles, toggle a dialog, etc.) into the "Options/Controls" dialog in the Torque Example application.
Consider you've got some code toggling NVG bitmaps while playing a mission (see http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2178 for this example).To get it into the re-mapping dialog, the first step is to make the function available in fps/client/scripts/default.bind.cs like that:
//------------------------------------------------------------------------------
// Night Vision Goggle HUD function
//------------------------------------------------------------------------------
function toggleNVG( %val )
{
if ( %val )
C3NV.toggle();
}
Then you map it to a default key, e.g.:
moveMap.bind(keyboard, "alt n", toggleNVG);Add it to fps/client/config.cs, too (this gets overridden by the inputs you make in the "Options" dialog):
moveMap.bind(keyboard, "alt n", toggleNVG);You could also use bindCmd, like that:
moveMap.bindCmd(keyboard, "alt n", "", toggleNVG);... but you don't really need bindCmd here (you would use it if you had different functions for depressing and releasing buttons; the syntax for that function is:
moveMap.bindCmd(device, inputName, downScript, upScript);
Then, in /fps/client/scripts/optionsDlg.cs add the new function for remapping and increase the remap count:
$RemapName[$RemapCount] = "Toggle NVG"; $RemapCmd[$RemapCount] = "toggleNVG"; $RemapCount++;
That's all - now you can change the input mappings for your custom function in the "Options/Controls" dialog by double clicking the new entry "Toggle NVG"!