Game Development Community

Default Bind and....

by Andy Hawkins · in Torque Game Engine · 06/06/2006 (1:22 am) · 9 replies

When I add key presses, and mouse click commands to default.Bind.cs found in the client/scripts folder, I notice that client/scripts/client/config.cs sometimes gets modified and sometimes does not.

Also the file client/config.cs seems to get updated sometimes, and sometimes not.

If I want another user to use the same default.Bind.cs file when doing a resource/content pack etc. should I be supplying all 3 files or just the defaultBind.cs file?

#1
06/06/2006 (3:46 pm)
First of all, the file client/scripts/client/config.cs should not exist. It's created erroneously by a bug in the TGE scripts. In file client/scripts/optionDialog.cs replace the line:
moveMap.save( "./client/config.cs" );
with
moveMap.save( "~/client/config.cs" );

Now, if you look closely at client/config.cs you will notice that the first three lines are:
// Torque Input Map File
moveMap.delete();
new ActionMap(moveMap);

As client/config.cs is executed after default.bind.cs that means that every binding you set up in default.bind.cs is completely ignored and overwritten by the bindinds in client/config.cs.

Whenever you change default.bind.cs you should manually delete client/config.cs. It will be regenerated automatically. If you want another user to use your bindings, you should either ship both files or ask the other user to delete client/config.cs.
#2
06/06/2006 (4:38 pm)
Finally someone has described how this works; thanks Alberto.
#3
06/07/2006 (1:54 am)
Yep thanks Alberto - it was driving me nuts!
#4
07/21/2007 (12:57 am)
In TGEA config.cs doesn't seem to get rewritten when I delete it after changing default.bind.cs - is this a bug / known issue - is there a patch?

It's seem I have to change entries in config.cs myself.
#5
07/23/2007 (10:28 am)
It works for me. Are you sure you are deleting the correct file?
#6
07/23/2007 (3:26 pm)
I just tried it again. I deleted config.cs in the /client folder, ran the game and it did not regenerate it. I had not controls, just default mouse and editor controls. What part of the engine regenerates the config.cs file? I should check there and see if there's a bug.
#7
07/23/2007 (3:43 pm)
Right now the only thing that re-generates it is the saving of the "options" screen. That could easily be fixed by changing client/init.cs to execute "moveMap.save" after default.bind.cs is read. However, this would never allow a user to change their key bindings from the default values beyond a single game session, so you should probably do whatever is best from your game's perspective.
#8
07/23/2007 (4:38 pm)
How's it supposed to work? I thought that any inclusions I make in the default.bind.cs are automagically replicated in config.cs right? That's the functionality I want. Right now it's not doing that.

I make a change to default.bind.cs and I have to manually type in the change to config.cs - this is for TGEA by the way.
#9
07/24/2007 (9:28 am)
Well, you have a couple options there. First of all, it is okay if there is no config.cs file. Your new bindings from default.bind.cs will work just fine. Config.cs was designed so the player could customize their controls. The easy way to ensure that new keys get added to config.cs is to re-save the moveMap into that file every time the game loads. However, that will wipe out any custom key bindings the player has created. Your other option is to do something much fancier where you (somehow) only detect which key bindings don't already exist and insert only those. However, you're looking at custom code to do that.