Custom functions in the 'Options/Controls' dialog
by Stefan Beffy Moises · 02/17/2002 (8:21 am) · 2 comments
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, a cool tutorial written by Stefan "Gruff" Grufman).
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"!
Happy toggling!
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"!
Happy toggling!
#2
I really like those goggles, by the way!
02/17/2002 (1:23 pm)
Yes, would be a good idea to add it to your tutorial ;-)I really like those goggles, by the way!
Torque Owner Stefan Grufman
Kewl!
/Stefan