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
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);
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.