Bridge Commander Central

BC Forums => BC Scripting => Topic started by: vonfrank on March 05, 2009, 11:06:55 PM

Title: Default key bindings
Post by: vonfrank on March 05, 2009, 11:06:55 PM
Is there any way to add a command to a keyboard shortcut?

for example, i want to add the "redistribute shields" command to a keyboard button like "CTRL-S" or something.

there are other things i would like to make shortcuts for but i need to know how first

any sudgestions would be appreciated :D
Title: Re: Default key bindings
Post by: MLeo on March 06, 2009, 09:44:07 AM
The easiest way is to use my KeyFoundation, included in KM, it's old and buggy, but it does work, most of the time.
Look in WalkFX on how to use it.

Don't forget, you have to assign the actual key in the key config (options menu)!
Title: Re: Default key bindings
Post by: vonfrank on March 06, 2009, 03:50:28 PM
Thanks  :D

ill let you know if i need any more help
Title: Re: Default key bindings
Post by: vonfrank on March 09, 2009, 09:50:22 PM
alright, i tried to understand what is in the file you sudgested, and i copiyed the approrpiate lines into the "Redistribute shields" file and changed the text to pretain to it, but it did not work, the "Redistribute shields" button dissapeared and no new key binding option appeared in the config. menu

if you can spare the time, i would appreciate a step by step procedure on what to copy into what files

thanks  :D
Title: Re: Default key bindings
Post by: MLeo on March 10, 2009, 10:59:49 AM
If the button suddenly dissappeared, then an error occurred before that particular code could run, please get a console report.
Title: Re: Default key bindings
Post by: vonfrank on March 22, 2009, 10:18:03 PM
it still wont work

here is the file, if anyone knows how to fix it please try
Title: Re: Default key bindings
Post by: MLeo on March 23, 2009, 03:41:56 PM
Here is a hint, where do you think "mode" comes from?
Title: Re: Default key bindings
Post by: vonfrank on March 23, 2009, 05:13:21 PM
i'm not really sure  :shock:

any tips?
Title: Re: Default key bindings
Post by: MLeo on March 23, 2009, 06:04:04 PM
Remove the , { ... } part and try again, it should (if memory serves) default to a stock mutator.
Title: Re: Default key bindings
Post by: vonfrank on March 23, 2009, 06:23:46 PM
still didn't work

i changed it to:

Foundation.g_kKeyBucket.AddKeyConfig(Foundation.KeyConfig("Redistribute Shields", "RedistributeShields", ET_KEY_EVENT, App.KeyboardBinding.GET_INT_EVENT, 1, "Ship" ))


is that what you meant
Title: Re: Default key bindings
Post by: MLeo on March 23, 2009, 06:35:28 PM
So you don't get a Redistribute Shields option in the Ship key options?

Try to first start a QB before heading into the key options.

Since you are using QBAutoStart it's possible that it isn't loaded untill then.
Title: Re: Default key bindings
Post by: vonfrank on March 23, 2009, 07:02:48 PM
well now i have the button in the config menu

but the binding wont work when i press it

is there some other file i need to put the binding info in to make the action work?
Title: Re: Default key bindings
Post by: MLeo on March 24, 2009, 12:17:08 PM
Well, for starters, you don't bind "ET_KEY_EVENT" to anything.

First you have to create a new one (before it!) through this:
Code: [Select]
ET_KEY_EVENT = App.UtopiaModule_GetNextEventType()And then you need to bind it. In this case (mostlikely) to:
Code: [Select]
App.TopWindow_GetTopWindow().FindMainWindow(App.MWT_OPTIONS).AddPythonFuncHandlerForInstance(ET_KEY_EVENT, __name__ + ".RedistributeShields")
Title: Re: Default key bindings
Post by: vonfrank on September 15, 2009, 12:51:49 PM
sorry for bringing this up again from so long ago, but i got distracted with Galaxy Charts 2.0 and other new mods released recently.

in regards to your last post...
i am a little confused on where exactly i put those lines of code
do i place them in the Redistribute shileds file or do i put them somewhere else?

some parts of python modding are easy to get, but others are difficult for me, sorry
Title: Re: Default key bindings
Post by: teleguy on September 15, 2009, 06:53:38 PM
sorry for bringing this up again from so long ago, but i got distracted with Galaxy Charts 2.0 and other new mods released recently.

in regards to your last post...
i am a little confused on where exactly i put those lines of code
do i place them in the Redistribute shileds file or do i put them somewhere else?

some parts of python modding are easy to get, but others are difficult for me, sorry
I've attached the relevant files so you can to take a look at them. FYI this will also add a "Redistribute Shields" mutator to the game.

I'll further look into the matter tomorrow to see if there's a less complicated way.
Title: Re: Default key bindings
Post by: vonfrank on September 15, 2009, 11:05:46 PM
Unfortunately it still doesn't work

i get the mutator and the binding option in the config. menu and if you click the redistribute shields button from the tactical officer menu it works fine but i set the binding to work when you press the "f" key, however nothing happens when i do so.  :(
Title: Re: Default key bindings
Post by: teleguy on September 16, 2009, 02:24:06 AM
Strange, it works for me. Does the console say anything after you pressed the button?
Title: Re: Default key bindings
Post by: vonfrank on September 16, 2009, 04:08:38 PM
the console report doesn't mention anything about it

the shortcut simply doesn't work for me  :'(
Title: Re: Default key bindings
Post by: teleguy on September 17, 2009, 05:58:20 AM
Do the key bindings for other mods work?

Anyway you probably have to wait for MLeo in order to fix this.
Title: Re: Default key bindings
Post by: vonfrank on September 17, 2009, 06:14:02 PM
Yes they do

only this one (as far as i know) doesnt work
Title: Re: Default key bindings
Post by: vonfrank on September 19, 2009, 11:28:27 PM
OK Problem solved   :D

i dont know what exactly the issue was but after re-installing the entire game (including KM and Galaxy Charts) the shortcut worked

thanks for all of the help everyone  :)
Title: Re: Default key bindings
Post by: NeoKaede on September 22, 2009, 11:24:03 AM
Thanks from me too. The script works perfectly :)