Skip to main content

Store

Store is a central point for storing and retrieving data in the profile. It is used to store the current state of the profile, such as the current value of the knob or the current state of the switch.

Schema

Each store property should consist of simVar for MSFS and ref for X-Plane.

MSFS

MSFS uses simVars to store data. A simVar is a variable that can be read and written (not always) by the simulator and external program like SimBox. You can find a list of simVars in the MSFS SDK documentation.

Some of the variables doesn't figure in the SDK documentation, but you can find them in the developer tools inside the simulator. This will be shown later.

{
"store": {
"variableName": {
"simVar":[
"L:EXAMPLE_VAR",
"number"
],
"parse":"return variableName;"
}
}
}

X-Plane

{
"store": {
"variableName": {
"ref": "sim/cockpit/example_var",
"parse": "return variableName;"
}
}
}

Parsing

The parse property is NOT MANDATORY, and it can be used to parse the value of the variable and return it. Parse is a function that takes the value of the variable as an argument and returns the value that should be stored in the profile. Parse logic should be written in JavaScript programming language.

Utilities:

  • lodash - you can use lodash functions in the parse function, for example, return _.round(value, 2) to round the value to 2 decimal places.
  • getStoreValue - you can access another store value by using getStoreValue('anotherValueName') if you need to use another store value in the parse function

Usage in components

Let's take as an example landing lights in the default B787 profile:

{
"store": {
"ldgLeftLightPosition": {
"simVar": [
"L:LIGHTING_LANDING_2",
"number"
],
"parse": "return ldgLeftLightPosition > 0 ? 2 : 0;"
}
},
"template": {
"screen_lights": {
"name": "Lights",
"canvas": {
"size": {
"width": 1090,
"height": 490
}
},
"components": [
{
"type": "switch",
"position": {
"x": 0,
"y": 70
},
"props": {
"topText": "LEFT\nOFF",
"bottomText": "ON",
"clickAreas": 2,
"storeKey": "ldgLeftLightPosition",
"onPressEvents": [
"ldgLeftLightSwitch"
]
}
}
]
}
}
}

As you can see, L_LIGHTING_LANDING_2 is stored in ldgLeftLightPosition and parsed to return 2 if the value is greater than 0. This value is then used in the switch component (storeKey property) to determine the position of the switch.

You can use one store value in multiple components.

Finding your variables

MSFS

There are many of ways of finding the sim vars in MSFS. You can use built-in developer tools or use the SDK documentation.

  1. Open developer mode in MSFS settings.
  2. In the toolbar at the top of the screen, click on Tools and then Behaviors.
  3. Navigate to the Local variables tab.
  4. Here you can see all the variables set by 3rd party software.

img.png

X-Plane

Searching for proper ref values in X-Plane is much easier than in MSFS. You can use the DataRefTool for that.

  1. Install the DataRefTool plugin.
  2. Open the plugin in the simulator (Plugins -> DataRefTool -> Search).
  3. Search for the ref you need.

img_2.png