• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSXA [Solved] How to lock a door?

Kekelekou

Resource contributor
Messages
226
Country
france
Hi there!

The BN-2 features a door locking system : the pilot's exit can not be opened if either left engine's magneto is powered. I am working on adding such a locking gauge on my favourite add-on.
FSX only allows us to play with "TOGGLE_AIRCRAFT_EXIT" event.
Would forcing this toggle event to 0 lock this door in the closed position? Something like in pseudo XML :

(Left mag:1) (Right mag:1) OR
if{
0 (K:TOGGLE_AIRCRAFT_EXIT)
}

Less specifically, does setting a "TOGGLE event" to 0 prevent the event?
Is XMLTools the only way?

Thank you for your input!
 
Last edited:
Try an event trap.

Code:
<Gauge>
<Keys>
<On Event="TOGGLE_AIRCRAFT_EXIT">
(Left mag:1) (Right mag:1) OR
if{ (>K:TOGGLE_AIRCRAFT_EXIT) }
</On>
</Keys>
</Gauge>
 
The event trap should use XMLEVENTS class from XMLToos, mostly because it is usual to open the doors when being in external view, using the keyboard shortcut.

Tom
 
Hello Björn and Tom,

Thank you for helping one poor XML-impaired gauge developer wannabe! I had no clue about what event traps are and their not working in external view.

TOGGLE events seem a bit ambiguous to me. Everything would have been much easier if we could play with KEY_OPEN_EXIT:index or KEY_CLOSE_EXIT:index...

----------
I am trying to have a go at XML only for now, for self-educational purposes. :p (notwithstanding the external view issue)
I am stuck with the following options, since door opening/closing animation is longer than one gauge update duration :

Option 1) If door-opening > 0, set TOGGLE_EXIT to 1
Option 2) If door-opening > 0, set TOGGLE_EXIT to 1 as long as the door is open; then if door_opening = 0, set TOGGLE_EXIT to 0
Option 3) If door-opening > 0, set TOGGLE_EXIT to 1 ONLY ONCE, then set TOGGLE_EXIT to 0


The question that lies underneath is : Are eventIDs reset to 0 once the event is triggered? Or does the value stick to the last set value? Do I need to cancel the order to prevent the door from "flickering" at everything gauge update?
 
Last edited:
Hi,

You cannot set toggle events to 0 or 1. When triggered they only force the object to its opposite state. Normally you do not place a 0 or 1 in front of these events, although it does no harm, AFAIK.

So what you need to do is first test which position it is in (in this case open or closed), and *if* in the wrong position trigger the toggle event.
 
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 &gt; &amp;&amp;
        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) &amp;&amp; (L:ClosingAllowed, bool) &amp;&amp;
        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.
 
Hi Tom,

Got it now! TOGGLE EventIDs do ont need arguments. The related event is "fired" everything the eventID is read.
 
There are some toggle events that accept numerical parameters, like aircraft exits, fire extinguishers and hydraulic systems.

Code:
4 (>K:TOGGLE_AIRCRAFT_EXIT)
21 (>K:EXTINGUISH_ENGINE_FIRE)
3 (>K:HYDRAULIC_SWITCH_TOGGLE)
 
That is correct, but AFAIK they don't set the toggle itself, only provide further information?
 
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 &gt; &amp;&amp;
        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) &amp;&amp; (L:ClosingAllowed, bool) &amp;&amp;
        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.
 
Last edited:
Thank you so much Rob for your very detailled and educational reply! :teacher:
Will test that tonight.
 
The SDK indicates that the EXIT OPEN variable is settable. If you're going to use XMLTools, why not use the SimVars class to force the EXIT OPEN variable to zero. You won't have to use a trap of any kind to do that.
 
Just for the record, tried some of the suggestions on my SP2 setup (yes, I know, not exactly cutting edge, dinos rule OK etc):

2 (>K:TOGGLE_AIRCRAFT_EXIT)

opens/closes the main door, all other exits remaining firmly closed, Whereas:

(>K:TOGGLE_AIRCRAFT_EXIT) (>K:SELECT_2)

works as advertised.

A version matter perhaps? Or butterfingers maybe?
 
Just for the record, tried some of the suggestions on my SP2 setup (yes, I know, not exactly cutting edge, dinos rule OK etc):

2 (>K:TOGGLE_AIRCRAFT_EXIT)

opens/closes the main door, all other exits remaining firmly closed, Whereas:

(>K:TOGGLE_AIRCRAFT_EXIT) (>K:SELECT_2)

works as advertised.

A version matter perhaps? Or butterfingers maybe?
Most probably the first; probably one of those many subtil (and, as far as I know,: undocumented) differences between FSX-SP2 and the implementation of SP2 included in FSX-Accell ..

Rob
 
Nailed it, Rob!
With 1 (>K...), the door handle is actuated, but the door remains closed all along. The nicest result I could have dreamt of!
Thanks to you and you all who have helped!
 
The SDK indicates that the EXIT OPEN variable is settable. If you're going to use XMLTools, why not use the SimVars class to force the EXIT OPEN variable to zero. You won't have to use a trap of any kind to do that.

Doug, when doing tests I didn't succeed in assigning a value to the EXIT OPEN variable with Simvar class. It is always overwritten by its previous status.

Tom
 
Back
Top