Clear Aircraft Lvars after unload of that Aircraft

Currently when a User switch from one Aircraft to another, all Lvars from the
previous Aircraft are still present. This causes Issues with Addons like
FSUIPC and Applications which build upon that (like my StreamDeck-Plugin). The
Issue being that some Lvars can’t be accessed. See:
<Missing LVAR after 3066 Lvars loaded (since SU11) - FSUIPC7 MSFS - The simFlight Network Forums
since-su11/> The Lvars should be cleared after the Aircraft was unloaded -
they are not usable anymore anyway!

LVars are not assigned to a specific aircraft, they are globally accessible
and can be read/write by anything in-sim without the need for a context. We
(//42) use it for various things that aren’t even related to an aircraft. That
makes it near impossible to track and remove when an aircraft is switched.

So it becomes up to the “New loaded aircraft” to Initialize any critical Lvars
it uses to an appropriate know state ? Good to know .

Yep! Not only do we initialize some vars when the aircraft is loaded, We also
use unique var names (P42_FF_*) to ensure it doesn’t conflict with anything
else

Well it comes down to the internal Handling of MSFS - it can correlate the
Creator with the L-Var, it could know when to clear it.

Another way to solve this problem would be to clear the Lvars when the
aircraft is “unloaded”, that is when the user switches to another aircraft or
ends the flight. So the question is: Is there a way to detect this? I knew how
to do it with FSX but not with MSFS :slight_smile: