T3D/Howtos/ Custom Keybinds

From TDN

Custom KeyBinds


So, you've made a new keybind, and as an example, let's say you've created a custom weapon and made a keybind for it.

In game/scripts/client/default.bind.cs you've added this new keybind, just like the rest.


moveMap.bindCmd(keyboard, "3", "commandToServer('use',\"NoobCannon\");", "");


But that's not all. To have it work you have to also have a copy of of the keybind in game/script/client/config.cs - which is what your project reads for input. Rather than add it manually, we'll let the project regenerate all the keybinds and add it automatically for us - that way you won't accidentally make a typo or have anything else go wrong that might prevent the game from using it.


In you project folder (eg: T3D 1.x/My Projects/Your_Project_Name) there are a number of *.bat files for regenerate everything from shaders to prefs.

deletePrefs.bat

Keybindings come under prefs, so by double-clicking this deletePrefs.bat your Project's current preferences and keybound config fiels will be deleted and then regenerated when you restart your Project - fully up to date to reflect any changes that you have made. Now your new keybind commands will work in-game.

This way any sensitive key structures will be automatically fixed for Project reading:

eg:

//eg: a default.bind.cs 
moveMap.bindCmd(keyboard, "3", "commandToServer('use',"NoobCannon");", "");
//becomes
moveMap.bindCmd(keyboard, "3", "commandToServer('use',\"NoobCannon\");", "");
//in config.cs