Actions
Actions are the response instructions to the events that are triggered by the user. Each action is a set of instructions that will be executed.
Schema
Event actions
Event actions are the instructions that will be executed for a non-knob event. For example, a button press.
MSFS
{
"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"
]
}
}
]
}
},
"action": {
"event": {
"ldgLeftLightSwitch0": [
{
"setSimVar": ["K:LANDING_LIGHTS_TOGGLE", "numeric", 2]
}
],
"ldgLeftLightSwitch1": [
{
"setSimVar": ["K:LANDING_LIGHTS_TOGGLE", "numeric", 0]
}
]
}
}
}
Note, that each Switch
component has two onPressEvents
- ldgLeftLightSwitch0
and ldgLeftLightSwitch1
- it depends on the target position of the switch.
Other events, like buttons press, can be handled in the same way.
{
"template": {
"screen_lights": {
"name": "Lights",
"canvas": {
"size": {
"width": 1090,
"height": 490
}
},
"components": [
{
"type": "button",
"position": {
"x": 940,
"y": 50
},
"props": {
"title": {
"value": [
"WING"
]
},
"storeKey": "wingStatus",
"onPressEvents": [
"wingButtonClick"
]
}
}
]
}
},
"action": {
"event": {
"wingButtonClick": {
"events": [
{
"setSimVar": ["K:TOGGLE_WING_LIGHTS", "numeric", 1]
}
]
}
}
}
}
X-Plane
X-Plane actions are similar, the only difference is we send pure array of strings instead of "setSimVar" object.
{
"action": {
"headingButtonClick": {
"events": ["laminar/B738/autopilot/hdg_sel_press"]
}
}
}
Knob actions
Knob actions are similar to event actions, but they are triggered by the knob rotation.
The property name should correspond to the slotName
of the knob component.
{
"action": {
"knob": {
"com1": [
{
"inputEvents": ["lowerKnobClockwise"],
"events": [
{
"setSimVar": ["K:COM_RADIO_WHOLE_INC", "bool", true]
}
]
},
{
"inputEvents": ["lowerKnobCounterclockwise"],
"events": [
{
"setSimVar": ["K:COM_RADIO_WHOLE_DEC", "bool", true]
}
]
},
{
"inputEvents": ["upperKnobClockwise"],
"events": [
{
"setSimVar": ["K:COM_RADIO_FRACT_INC", "bool", true]
}
]
},
{
"inputEvents": ["upperKnobCounterclockwise"],
"events": [
{
"setSimVar": ["K:COM_RADIO_FRACT_DEC", "bool", true]
}
]
},
{
"inputEvents": ["push", "pull"],
"events": [
{
"setSimVar": ["K:COM1_RADIO_SWAP", "bool", true]
}
]
}
]
}
}
}
Input event types:
lowerKnobClockwise
lowerKnobCounterclockwise
upperKnobClockwise
upperKnobCounterclockwise
push
pull
It is important to configure that properly in order to have a proper knob rotation response. If the knob doesn't have the "upper" part (for example C172 autopilot heading knob), include it in the configuration as well, to avoid uses confusion when using physical knobs.
Finding correct simVar or ref
MSFS
There are 2 ways of saving data in the simulator - simVars and actions. SimVars are used to store data, and actions are used to trigger events. SimVars and how to access them are described in the store section.
Unfortunately, finding correct action name is much harder than finding correct SimVar. You can use developer tools in the simulator to find the correct action name. Please remember, that there is no pattern in action names, so you have to find it manually. Each developer may name the action differently.
- Open developer mode in MSFS settings.
- In the toolbar at the top of the screen, click on
Tools
and thenBehaviors
. - Navigate to the
Behaviors
tab. - Search for the component you want to find the action name for.
- Browse the component code to find the action name.
In this example we can see, that L:VC_Miscellaneous_trigger_VAL
accepts 19
and 18
values for changing landing lights state.
X-Plane
Searching for proper action names in X-Plane is much easier than in MSFS. You can use the DataRefTool for that.
- Install the DataRefTool plugin.
- Open the plugin in the simulator (Plugins -> DataRefTool -> Search).
- Search for the
action
name you need.