I have managed to have the gauge working as expected with the following code :
Code:
(A:RECIP ENG LEFT MAGNETO:1, bool) (A:RECIP ENG RIGHT MAGNETO:1, bool) || (A:EXIT OPEN:0, percent) 10 > &&
if{
2 (>L:Stall_Sound, bool)
}
els{
0 (>L:Stall_Sound, bool)
}
(A:RECIP ENG LEFT MAGNETO:1, bool) (A:RECIP ENG RIGHT MAGNETO:1, bool) ||
if{
(A:EXIT OPEN:0, percent) 0 ==
if{
1 (>L:DoorIsLocked, bool)
1 (>L:ClosingAllowed, bool)
}
}
els{
0 (>L:DoorIsLocked, bool)
}
(A:EXIT OPEN:0, percent) 0 != (L:DoorIsLocked, bool) && (L:ClosingAllowed, bool) &&
if{
(>K:TOGGLE_AIRCRAFT_EXIT)
0 (>L:ClosingAllowed, bool)
}
L:ClosingAllowed makes sure that the TOGGLE event is a one-shot only.
The only issue left is that the door opens quite a bit (half way through) before being closed again. Even with a 18 update rate.
About your react-time issue:
As described in above posts, the FS Exit function only has a Toggle event; no On, Off, or Set event like many other functions.
Now, the problem with a single TOGGLE_AIRCRAFT_EXIT is, that FSX waits about 1 sec before it executes the event.
Reason: to allow the user to select an Exit , eg with a keystroke like "1" (default, which gererates the event SELECT_1).
This explains why your door is opened quite a bit before it reacts to your TOGGLE_AIRCRAFT_EXIT event to close it again.
To solve this, use:
Code:
1 (>K:TOGGLE_AIRCRAFT_EXIT)
which bypasses the wait time.
Note that "1" (like SELECT_1) toggles the first Exit, which is identied as EXIT OPEN:0 in the related Avar.
Unlike other functions, like Engine, where the Avar uses ENGINE:1 for the first engine ....
Some more info:
The method you use now, is based on "correcting" a function after-the-fact, based on the state of the related Avar , by giving another event.
So there will allways be a little reaction time, depending on the schedule frequency of the code.
The same applies if you would use the OnEvent coding as described above.
Because in FSX-A there is a difference between trapping keys and events:
- Trapping an event (On Event): the event is still executed, so in the OnEvent code you can "correct" the user action. But it still is "correction"
- Trapping a key (On Key): the keystroke is actually trapped and NOT executed.
And this trapping (events or keys) only works if the gauge that runs it, is defined in a panel window that is actually visible.
So, as Tom says, if the gauge is defined in the VCsection and you are in SPotplane view, the trapping doesn't work ....
This is, a.o., what Tom solved in his XMLtools module.
But the code you have now, with my addition to use
Code:
1 (>K:TOGGLE_AIRCRAFT_EXIT)
is the simplest and does the trick you want ....
Rob
To avoid any confusion: in
Code:
1 (>K:TOGGLE_AIRCRAFT_EXIT)
"1" still toggles the Exit, but only Exit-1 but without wait-time.
Like
Code:
3 (>K:TOGGLE_AIRCRAFT_EXIT)
will toggle Exit-3 (Avar EXIT:2), without wait-time.