plane icon Welcome to Microsoft Flight Simulator’s SDK Q&A Platform!

You have questions regarding the SDK? DevMode Tools? SimConnect? You would like to submit an idea for future improvements, seek help or exchange knowledge? You’re in the right place.

Please take a moment to read the platform’s guidelines before you get started!

question

RipPipPip avatar image
RipPipPip asked virtuali edited

How to create own SimVar for use by SimConnect (to change its value from outside MSFS)

Hi,

two days of studying this forum and all of the Google and I am still stuck - my question is:
how to create own SimVar for use by SimConnect (to change its value from outside MSFS) ?

Is it possible already? I do not like to mess with existing variables...

BTW: I have read and even generated a sample SimvarWatcher application.


Regards,
Rysiek


simconnect
10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

virtuali avatar image
virtuali answered

SimVars such as A: variables, which are independent for each SimObject cannot be created. The list of available variables changes depending by the kind of SimObject, with the User airplane having the largest set, AI planes a bit less ( but some extra specific to AI ), ground vehicles less, and Static objects even less. These are read/written using Simconnect, either from external .EXE or from WASM modules.

You can create any number of L: variables, which are instead "global", not tied to a specific SimObject. You cannot read or write these from SimConnect ( one of the most voted suggestions here asked for the ability to do so ), so the easiest way to use them is to create a WASM module, either as a Gauge or as a stand-alone module, which can access to the Gauges API that provides a series of functions to register, read and write these "user" variables, without Simconnect.

The only way to give access to these variables to an external .EXE, is to write a WASM module that can use L: variables, and use Simconnect custom client data functions to transmit these variables and their values to an external Simconnect .EXE client. There are several modules doing this, but we are trying to convince Asobo to add direct support for L: ( and H: ) variables from Simconnect, in order not to have dozen of WASM modules all doing the same thing, needlessly increase traffic over Simconnect.

10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

RipPipPip avatar image
RipPipPip answered

OK, understood :/

10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

RipPipPip avatar image
RipPipPip answered RipPipPip edited

So... I still not clearly understand that:

may I use any chosen (by me) existing variable/variables, associated for example with:
"Services Specific Variables":

for example -

CATERINGTRUCK ELEVATION CURRENT

and attach this variable in XML code of my own static object?

If I will change the value of the variable from outside by SimConnect,

will it work "for me" or will it crash all of MSFS catering trucks as well??


10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

RipPipPip avatar image
RipPipPip answered virtuali edited

So I've made two attempts:


CODE_A:

<?xml version="1.0" encoding="utf-8"?>

<ModelInfo guid="{dde7e4d0-dc1c-4ff4-8fcf-11490e798479}" version="1.1">

<LODS>

<LOD ModelFile="poi_00603_LOD00.gltf"/>

</LODS>

<Behaviors>

<Include ModelBehaviorFile="Asobo\Generic\FX.xml"/>

<Component ID="component_poi_00603" Node="node_poi_00603">

<UseTemplate Name="ASOBO_GT_Visibility_Code">

<VISIBILITY_CODE>(A:TAILHOOK POSITION, number) flr 128 & 0 &eq;</VISIBILITY_CODE>

</UseTemplate>

</Component>

</Behaviors>

</ModelInfo>

RESULT_A: CTD of MSFS, when trying to spawn at the scenery.


CODE_B:

<?xml version="1.0" encoding="utf-8"?>

<ModelInfo guid="{dde7e4d0-dc1c-4ff4-8fcf-11490e798479}" version="1.1">

<LODS>

<LOD ModelFile="poi_00603_LOD00.gltf"/>

</LODS>

<Visibility>

<Parameter>

<Code>

(A:TAILHOOK POSITION, number) flr 128 & 0 &eq;

</Code>

</Parameter>

</Visibility>

</ModelInfo>

RESULT_B: Airplane is flying there, I see my object but changes by SimConnect to "TAILHOOK POSITION" SimVar made no difference in visibility - the object was still visible.


PS. Today SDKv13 was released but I was not able to find "Behaviors" nor "Visibility" description.

3 comments
10 |10000 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Code A should work.


However, you included the wrong file, since the FX.XML file doesn't include that template definition, which is in Asobo\Generic\Visibility.xml instead.


And, your visibility code could probably be streamlined like this:


(A:TAILHOOK POSITION, number)

This will make the object appear if the variable as any value other than zero


If you want the opposite effect:

(A:TAILHOOK POSITION, number) 0 ==

This will make the object appear only if the variable is zero


And:

(A:TAILHOOK POSITION, number) 128 ==

This will make the object appear only if the variable is 128

0 Likes 0 ·

Thanks!


Actully the code I tried to design was meant to be like that: every bit of the number will switch ON/OFF different group od POIs :)

Anyway:

objects should be SimObjects and not scenery objects (ArtProj), everything is explained in detail here -

MSFS - Visibility | FSDeveloper: https://www.fsdeveloper.com/forum/threads/visibility.449781/

0 Likes 0 ·

Yes, for behaviours to work, the object must be a Simobject.


Animations should work even in objects part of a library .BGL but, at the moment, the current Beta 1.18.9.0 is bugged, and animations in .BGL stopped to work, which has been reported in other threads, so I hope it will be fixed before release.

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.