Create simvars

Hello
I’m new to msfs SDK, I’ve been developing using P3D SDK for 3 years now and I used to use PDK + simconnect to achieve what I wanted

I’ve seen that MSFS has its own low API SDK but I can’t really know if it is reserved for aircraft’ gauges

My question is: can I create a simvar that doesn’t exist, like registering a new simvar is the sim that is associated with a simobject other than the players plane and access that simvar using a simconnect app that would intitate that simobject’s instance in the sim ?

I hope my question is clear
Thnx in advance
Redouane.

First off, I am not familiar with the FS 2020 SDK when it comes to creating simulation objects (like aircraft): I only know the API “from a client perspective”, notably the SimConnect API.

That said, I have been told that you can create so-called “local variables” (“L:vars”) and use those, e.g. for custom animations of certain aircraft parts. In fact, there are 3rd party aircraft which just do that. Probably the most prominent example is the A320 by FlyByWire.

Here’s the catch: those “local variables” are not (directly) exposed via the SimConnect API! That is the reason why aircraft like the FBW A320 stopped working reacting to simulation variables which control e.g. the engine thrust etc. (because they are using their own “local variables” now to simulate the engine, or so I understand).

That is, there is no “official API” to access those local variables (identified e.g. by their name or so). Or not that I know of, at least.

However there are approaches (already discussed here in the forum) how you can access those local variables (for both read and write) via the SimConnect API, essentially via “custom events” (if I remember correclty). The drawback: you need to register your custom event IDs with SimConnect, and those registered custom event IDs might clash with IDs registered by other 3rd party apps (extensions) that run at the same time. And needless to say that those solutions are then “aircraft specific”, as the local variables are specific to the simulated object (of course - because they are “local” ;)).

And the second (potential) drawback: you also need to install an extension (a WASM module?) in FS 2020 itself, which then “reacts” to your “custom events” (as sent by the 3rd party app, via SimConnect).

Also refer to this thread there:

(and all the 100+ follow-up posts ;))

Hello
Thank you for your reply this looks interesting
However I stumbled on this particular part of the RNP documentation is the SDK docs

It can be found here :

https://docs.flightsimulator.com/html/Additional_Information/Reverse_Polish_Notation.htm?rhsearch=Rpn&rhhlterm=Rpn

It clearly mentions custom simvars accessed by the Z extension so creating SimVars is actually possible but not documentation about it ( unless I overlooked it)

Would you please check it out and tell me what you think ? Thnx in advance

Regards

1 Like

Well, as I said, I am not familiar with the SDK when it comes to creating addons which run within FS 2020 (either as WASM module, or whatever deployment model exists).

So for me this page merely enumerates the various variable types that you can use when creating e.g. your own “simulation object” (aircraft, airport, AI vehicles, …).

That said, I cannot even tell what the difference between a “local” and a “custom” variable would be. I can only guess (from the short docu snippet) that “custom variables” are stored together with the model (that is, they are “part of the model” as stored in the community folder, and possibly they retain even their value - by persisting it - over sessions), whereas “local” variables are probably volatile: they are created when the model is loaded into memory, they remain in memory but as soon as the model is “unloaded” those local variables are removed from memory as well - and newly initialised “from scratch” the next time the model is loaded.

But that’s all besides the point, namely that you cannot access those variables - “custom” or “local” - via the SimConnect API. Unless you make them accessible - programatically, with custom events - as mentioned above.

The only variables that are (directly) accessible (for read operations, most of the time also write) are the so-called “simulation variables” (in the linked documteation about the reverse polish notation prefixed with A), as documented here:

https://docs.flightsimulator.com/html/Programming_Tools/SimVars/Simulation_Variables.htm

It clearly mentions custom simvars accessed by the Z extension …

… from within an FS 2020 addon itself. Not via SimConnect. Remember: this chapter about the reverse polish notation is meant for addon developers that create simulation objects (again, aircraft, airports, AI vehicles, …), not for clients accessing the simulation state via the SimConnect API.

I guess I haven’t been clear, I want to develop as you call it " an addon": a simobject and I want to learn how to create custom vars knowing that my simobject is not playable, thus no gauges are needed, but still, I want to access it’s vars from a simconnect app( doable once the vars are created)

Yes, and I fully understood you request, and my answer was that A) you can create your own variables (“local variables”, “custom variables”… you name it) within your addon but B) you cannot directly access them via the SimConnect API, unless with “custom events” and some extra effort (an extra WASM module which “reacts” to those custom events and sets/gets the requested variables), as explained in great detail in the post that I linked to.

Perhaps my answer wasn’t clear to you :wink:

I don’t understand how to create a custom variable.

// SimConnect data definitions
enum DATA_DEFINE_ID {
DEFINITION_DATA,
DEFINITION_PDR,
DEFINITION_CUSTOM_DATA,
};

in the simconnect inspector only 2 are visible. Why? Thanks