KEYS.BSF

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

KEYS.BSF

Post by enric »

In this file there is a function for debug
FUNCTION KEYBOARD_DEBUG(me, key,tilex,tiley)

but tilex, tiley always return 0

is there a way to know where the cursor position is?
pipfromslitherine
Site Admin
Site Admin
Posts: 9863
Joined: Wed Mar 23, 2005 10:35 pm

Re: KEYS.BSF

Post by pipfromslitherine »

KEYBOARD_ functions only get passed in the me and key values. I'm not sure why that debug function has the other params, but they will always be zero, as you see.

Cheers

Pip
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: KEYS.BSF

Post by enric »

is there a way the catch the pressed key when there no unit selected?
pipfromslitherine
Site Admin
Site Admin
Posts: 9863
Joined: Wed Mar 23, 2005 10:35 pm

Re: KEYS.BSF

Post by pipfromslitherine »

I don't think so. It would be too easy to interfere with the main UI key handling.

Cheers

Pip
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: KEYS.BSF

Post by enric »

but in fact, with no unit selected, you can push N or TAB and goes to the first unit id.
pipfromslitherine
Site Admin
Site Admin
Posts: 9863
Joined: Wed Mar 23, 2005 10:35 pm

Re: KEYS.BSF

Post by pipfromslitherine »

You can attach a key to a UI object, yes. If you have your own UI control active then you can attach keys to them in the same way as BattleAdvancedPanel for example.

Cheers

Pip
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: KEYS.BSF

Post by enric »

I already put a
COMMAND KEY 4 (for example in the button:

[BAPAFVUnitsButton]
type button
x 300
y 3
width 54
height 54
file IPOD_AFV.tga
sfxfocus 7
sfx 5
COMMAND KEY 4
tooltip IDS_BAP_AFV

The UI_OBJ_HANDLE(data, event, id) works with, or without, a unit selected, but the shortcut "4" works only if catch it in the Keys.bsf

example:
if( IsUIObject(id, "BAPAFVUnitsButton") == 1 )
{
printHeader ("AFV");
printUnits(GetCurrentSide(), 1);
}
this works when the button in the advanced panel is clicked, with or without a unit selected.
but the "4" don't. I need to put in KEYS:
if(key == 52)
{
// number 4 keyboard
printHeader ("AFV");
printUnits(GetCurrentSide(), 1);
}
pipfromslitherine
Site Admin
Site Admin
Posts: 9863
Joined: Wed Mar 23, 2005 10:35 pm

Re: KEYS.BSF

Post by pipfromslitherine »

Ah - right. I remember now (I think!) it's actually a way for a UI control to trigger a key press (e.g. the 1 key was being used prior to the (iPad) bar of additional controls. So the button press triggers a key event. Hence the behaviour you are seeing.

Hmmm - not sure if there is any way around it that without a code change.

Cheers

Pip
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: KEYS.BSF

Post by enric »

pipfromslitherine wrote:Ah - right. I remember now (I think!) it's actually a way for a UI control to trigger a key press (e.g. the 1 key was being used prior to the (iPad) bar of additional controls. So the button press triggers a key event. Hence the behaviour you are seeing.

Hmmm - not sure if there is any way around it that without a code change.

Cheers

Pip
But there is a different behaviour between the 1 key and the N key, in the first case the code triggered is in KEY.BSF but in the second case no (I could not find it for now. This second case is the clue, because it is triggered even without a unit selected.
pipfromslitherine
Site Admin
Site Admin
Posts: 9863
Joined: Wed Mar 23, 2005 10:35 pm

Re: KEYS.BSF

Post by pipfromslitherine »

The N key is captured in code, it's one of the main game key shortcuts. The button just triggers the same keypress so that we don't have to have two flows into the logic.

Cheers

Pip
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: KEYS.BSF

Post by enric »

Tha's was I thought, just wanted to be sure.
Post Reply

Return to “Battle Academy : Modders Corner ”