This article covers the following platforms
MSFS 2024
MSFS 2020
ATS
FSX
Prepar3D
Read simulator and local variables, and write simulator variables, local variables, or events.
- Browse the MSFS simulation-variable reference.
- Browse the MSFS event-ID reference.
get()
Read a simulator or local variable in a requested unit.
SignatureTypeScript contract
get(var_name: string, unit: string): unknownParameters
| Name | Type | Required | Description |
|---|---|---|---|
var_name | string | Yes | Name of the variable to read. |
unit | string | Yes | Unit in which to read the variable. |
ExampleJavaScript
const parkingBrake = this.$api.variables.get(
"A:BRAKE PARKING POSITION",
"bool"
);
const tentSwitch = this.$api.variables.get(
"L:P42_FF_SWITCH_TENT",
"number"
);Returns
unknownCurrent value of the requested variable in the requested unit.set()
Write a simulator variable, local variable, or event.
SignatureTypeScript contract
set(var_name: string, unit: string, value: number): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
var_name | string | Yes | Name of the variable or event to write. |
unit | string | Yes | Unit of the value being written. |
value | number | Yes | Value to write. |
ExampleJavaScript
this.$api.variables.set("A:LIGHT LANDING", "bool", 1);
this.$api.variables.set("L:P42_FF_SWITCH_TENT", "number", 1);
this.$api.variables.set("K:PARKING_BRAKE_SET", "bool", 1);Returns
voidNo direct return value is documented.