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.
I try to set 2 different altimeters in my plane using XML, and it seems that it’s still impossible to use KOHLSMAN_SET with [0]: Value to set, [1]: Altimeter index,
Sets altimeter setting (Millibars * 16).
It always sets the altimeter #1, and never the altimeter #2, as if the altimeter index had no impact.
I tried many syntax with no joy.
Anyone has experienced the same?
In RPN code a K:2: event will take the last 2 values off the stack, so you just need to put the index and the kohlsman value on the stack then send to K:2:KOHLSMAN_SET e.g. 2 1013 16 * (>K:2:KOHLSMAN_SET) to set altimeter 2 to 1013 hPa.
This thread was about JS, where you need to use the key event listener to trigger multi-param events. There are no remaining items to be solved from this thread.