Page 1 of 1

Allow bos to capture keypresses when a unit is selected

Posted: 13 Apr 2010, 01:08
by Forboding Angel
With this, we could do all kinds of really neat stuff. I was kind of surprised that this functionality didn't already exist.

Basically so we can define hotkeys and trigger a function in a script. Would be 100 kinds of neato.

Re: Allow bos to capture keypresses when a unit is selected

Posted: 13 Apr 2010, 01:32
by CarRepairer
Gadgets create commands. Unit scripts animate upon those commands. Widgets can capture keypresses and can issue commands.

But, rather than capturing a keypress, the widget should make an ActionHandler action and the user can bind a key to it.

Re: Allow bos to capture keypresses when a unit is selected

Posted: 13 Apr 2010, 03:54
by Forboding Angel
That's fair. Was just pipedreaming :-)

Re: Allow bos to capture keypresses when a unit is selected

Posted: 15 Apr 2010, 13:26
by KDR_11k
Yeah, you're supposed to use the proper layer structure. I've got that toggle.lua gadget that I use for more or less direct hooks into BOS. One problem with a theoretical key-to-BOS hook is that key presses only go into the local unsynced, to communicate with the synced state you need a command or lua message so that information can be transmitted over the network to all participating players.

Re: Allow bos to capture keypresses when a unit is selected

Posted: 15 Apr 2010, 16:51
by CarRepairer
It's ok, we have a solution in the works. He wants to hook it to a special attack so there's no need for a gadget to create a command. He'll create the unit and weapon and I'll throw together a small widget that issues an attack-ground on keypress.

Re: Allow bos to capture keypresses when a unit is selected

Posted: 16 Apr 2010, 08:30
by KDR_11k
Hell, there's already a fairly universal gadget in Kernel Panic IIRC, it's how the Bug's transformation and the Byte's mine launcher work.

Re: Allow bos to capture keypresses when a unit is selected

Posted: 17 Apr 2010, 00:32
by AF
tbh this seems shaky on the sync vs desync ground to me at first