Using Event ID with index in JS

Hello, I would like to use event IDs that have index in my JS code. For
example, I would like to set each altimeter using KOHLSMAN_SET. The doc says
this about parameters: [0]: Value to set, [1]: Altimeter index, now how can I
use this in JS? To set altimeter with index 2, I tried all the following:

SimVar.SetSimVarValue("K:KOHLSMAN_SET", "number", 16212);   // Works, but sets ALL the altimteres
SimVar.SetSimVarValue("K:KOHLSMAN_SET:2", "number", 16212); // Does not work
SimVar.SetSimVarValue("K:KOHLSMAN_SET", "number", 16212, 2); // Does not work

Any clue? Thanks. Eric

My reading of the docs suggests a different approach - the KOHLSMAN SET event
is an example of one that takes TWO parameters: KOHLSMAN_SET |

[0]: Value to set

[1]: Altimeter index | Sets altimeter setting (Millibars * 16). | Shared
Cockpit
—|—|—|—
And the suggested RPN (I know you’ve asked Javascript):

  • Keys - these permit you to change the state of a component. Keys can have one or two arguments and are called as follows using the RPN format:

    [0] (>K:[key_event_name])
    

    [1] [0] (>K:2:[key_event_name])

Below are two examples, one with a single argument and the other with 2
arguments:

    1 (>K:TOGGLE_EXTERNAL_POWER)
50 1 (>K:2:PANEL_LIGHTS_POWER_SETTING_SET)

And in a nutshell I think you CANNOT program a multi-argument key event
directly in JS. You currently need to create a ‘bridge’ component in the
behaviours XML (using ASOBO_GT_Update) that you can feed THREE Z: variables,
one for the first parameter, one for the second, and you trigger the event
when you TOGGLE the third. I can provide an untested example of a suitable
component if it helps - my model XML is full of ASOBO_GT_Update components
doing all sorts of stuff…

I found this in the Working Title SDK: Coherent.call(‘TRIGGER_KEY_EVENT’, key,
bypass, index, value0, value1); Called like this:
Coherent.call(‘TRIGGER_KEY_EVENT’, ‘KOHLSMAN_SET’, true, qnhSetting * 16, 1,
0);

nice find!

I didn’t test this yet but it looks perfect. Thank you !!

I did get to testing this and it works as advertised. Don’t miss that you will
need this call once within that coherent context:
RegisterViewListener(‘JS_LISTENER_KEYEVENT’);

Indeed, it works perfect. Do you know what the bypass parameter is? I
think it is supposed to determine if the key event can be intercepted or not,
but when I set it to false, the value (1013*16) and the index are ignored and
it doesn’t work at all. In Asobo JS code I see it always used with bypass set
to true.