Simulation Instruments

Home›All functions›Simulators

Simulators

Simulation Instrument Studio 1

xpl_command

Simulation Instrument Studio 1

Overloads

xpl_command(commandref)

Fires an X-Plane command once, or begins and ends a held command.

Parameters

#NameTypeDescription
1commandrefStringReference to a command from X-Plane (see here)
2valueNumberOptional field. From AM/, you can set this argument to 'BEGIN', 'ONCE' or 'END' command. Older versions can use provide 1 for a BEGIN command, or 0 for an END command.

Example

-- Ident, once
xpl_command("sim/instruments/transponder_ident")
Photo slot: shots/xpl_command.png

xpl_command_subscribe

Simulation Instrument Studio 1

Overloads

xpl_command_subscribe(commandref,callback_function)

Calls back when a command begins, continues, or ends.

Parameters

#NameTypeDescription
1commandrefStringReference to a command from X-Plane. You can find the list of available commands here.
2callback_functionFunctionThe function to call when a new command has been sent within X-Plane

Example

xpl_command_subscribe("sim/instruments/transponder_ident", function(phase)
    -- phase is 0 begin, 1 continue, 2 end
    visible(ident_lamp, phase ~= 2)
end)
Photo slot: shots/xpl_command_subscribe.png

xpl_connected

Simulation Instrument Studio 1

Overloads

xpl_connected()

True when the plugin answers.

Parameters

#NameTypeDescription
1connectedBooleanTrue is connected, otherwise false.

Example

if xpl_connected() then
    remove(flag)
end
Photo slot: shots/xpl_connected.png

xpl_dataref_subscribe

Simulation Instrument Studio 1

Overloads

xpl_dataref_subscribe(dataref,type,...,callback_function)

Subscribes to one dataref, or several dataref and type pairs. The callback receives the values in that order.

Parameters

#NameTypeDescription
1 .. nvariableStringReference to a dataref from X-Plane (see X-Plane DataRefs)
2 .. nunitStringData type of the DataRef, can be INT,FLOAT,DOUBLE,INT[n],FLOAT[n],DOUBLE[n], BYTE[n] or STRING
lastcallback_functionFunctionThe function to call when new data is available

Example

-- One dataref, or several pairs. Values arrive in that order.
xpl_dataref_subscribe(
    "sim/cockpit2/gauges/indicators/altitude_ft_pilot", "FLOAT",
    "sim/cockpit2/gauges/indicators/airspeed_kts_pilot", "FLOAT",
    function(alt_ft, ias)
        txt_set(alt, tostring(math.floor(alt_ft)))
        rotate(needle, ias * 2)
    end)

Example: one value, and a pair

xpl_dataref_subscribe("sim/cockpit2/gauges/indicators/altitude_ft_pilot", "FLOAT", function(ft)
    txt_set(alt, tostring(math.floor(ft)))
end)

-- Both arrive together, in this order
xpl_dataref_subscribe(
    "sim/cockpit2/gauges/indicators/altitude_ft_pilot", "FLOAT",
    "sim/cockpit2/gauges/indicators/airspeed_kts_pilot", "FLOAT",
    function(ft, kts)
        txt_set(alt, tostring(math.floor(ft)))
        txt_set(ias, tostring(math.floor(kts)))
    end)
Photo slot: shots/xpl_dataref_subscribe.png

xpl_dataref_write

Simulation Instrument Studio 1

Overloads

xpl_dataref_write(dataref,type,value,offset,force)

Writes a dataref. The offset selects an array element.

Parameters

#NameTypeDescription
1datarefStringReference to a dataref from X-Plane (see X-Plane DataRefs)
2typeNumberData type of the DataRef, can be INT, FLOAT, DOUBLE, BYTE, STRING, INT[n], FLOAT[n], DOUBLE[n] or BYTE[n]
3valueNumberThe value to be written
4offsetNumberOptional field. Only to be used when writing arrays. Your value will start writing at a certain array offset. Starts at 0.
5forceBooleanOptional field, When true, the plugin writes the dataref every simulator frame. Make sure to disable the forcing again at some point in your code!

Example

-- Set the altimeter to 29.92
xpl_dataref_write("sim/cockpit2/gauges/actuators/barometer_setting_in_hg_pilot", "FLOAT", 29.92)
Photo slot: shots/xpl_dataref_write.png

msfs_connected

Simulation Instrument Studio 1

Overloads

msfs_connected()

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1connectedBooleanTrue is connected, otherwise false

Example

-- Simulator value, not a panel value
msfs_connected("INDICATED ALTITUDE", "Feet")
Photo slot: shots/msfs_connected.png

msfs_event

Simulation Instrument Studio 1

Overloads

msfs_event(event)
msfs_event(event, value_1)
msfs_event(event, value_1, value_2)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1eventStringReference to an event from Flight Simulator 2020/2024. Use 'H:' prefix for H events, see example below.
2value_1Number(Optional) Send a value with the event. Some events support setting a value.
3value_2Number(Optional) Send a value with the event. Some events support setting a value.

Example

-- Simulator value, not a panel value
msfs_event("INDICATED ALTITUDE", "Feet")
Photo slot: shots/msfs_event.png

msfs_event_subscribe

Simulation Instrument Studio 1

Overloads

msfs_event_subscribe(event, callback)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1eventStringReference to the FS2020/FS2024 event
2callbackFunctionThe function to call when a new event has been sent within the sim

Example

-- Simulator value, not a panel value
msfs_event_subscribe("INDICATED ALTITUDE", "Feet")
Photo slot: shots/msfs_event_subscribe.png

msfs_rpn

Simulation Instrument Studio 1

Overloads

msfs_rpn(rpn_script, callback)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1rpn_scriptStringThe RPN script to execute within FS2020/FS2024.
2callbackFunction(Optional) Return value from the executed RPN script. Three arguments are given, first is integer, second is float and third is string. Note that these arguments are nil when script could not be executed. Make sure to nil check in your callback.

Example

-- Simulator value, not a panel value
msfs_rpn("INDICATED ALTITUDE", "Feet")
Photo slot: shots/msfs_rpn.png

msfs_variable_subscribe

Simulation Instrument Studio 1

Overloads

msfs_variable_subscribe(variable, unit, callback_function)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1 .. nvariableStringReference to a variable from Flight Simulator 2020/2024. Use prefix 'L:' for LVARS, see example below
2 .. nunitStringUnit of the variable, can be found with the variable. Different units can be used for different variables. For example Hours, Knots and RPM
lastcallback_functionFunctionThe function to call when new data is available

Example

msfs_variable_subscribe("INDICATED ALTITUDE", "Feet", function(ft)
    txt_set(alt, tostring(math.floor(ft)))
end)
Photo slot: shots/msfs_variable_subscribe.png

msfs_variable_write

Simulation Instrument Studio 1

Overloads

msfs_variable_write(variable, unit, value)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1variableStringReference to a variable from Flight Simulator 2020/2024
2unitStringUnit of the variable, can be found with the variable. Different units can be used for different variables. For example Hours, Knots and RPM.
3valueNumberThe value to be written

Example

-- Simulator value, not a panel value
msfs_variable_write("INDICATED ALTITUDE", "Feet")
Photo slot: shots/msfs_variable_write.png

fs2020_connected

Simulation Instrument Studio 1

Overloads

fs2020_connected()

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1connectedBooleanTrue is connected, otherwise false

Example

-- Simulator value, not a panel value
fs2020_connected("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fs2020_connected.png

fs2020_event

Simulation Instrument Studio 1

Overloads

fs2020_event(event)
fs2020_event(event, type, value)
fs2020_event(event, value)
fs2020_event(event, value, value_2)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1eventStringReference to an event from Flight Simulator 2020. Use 'H:' prefix for H events, see example below.
2typeString(Optional) Data type, can be INT, FLOAT, DOUBLE, BOOL or STRING.
3valueNumber(Optional) Send a value with the event. Some events support setting a value.
4value_2Number(Optional) Send a value with the event. Some events support setting a value.

Example

-- Simulator value, not a panel value
fs2020_event("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fs2020_event.png

fs2020_event_subscribe

Simulation Instrument Studio 1

Overloads

fs2020_event_subscribe(event, callback)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1eventStringReference to the FS2020 event
2callbackFunctionThe function to call when a new event has been sent within FS2020

Example

-- Simulator value, not a panel value
fs2020_event_subscribe("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fs2020_event_subscribe.png

fs2020_rpn

Simulation Instrument Studio 1

Overloads

fs2020_rpn(rpn_script, callback)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1rpn_scriptStringThe RPN script to execute within FS2020.
2callbackFunction(Optional) Return value from the executed RPN script. Three arguments are given, first is integer, second is float and third is string. Note that these arguments are nil when script could not be executed. Make sure to nil check in your callback.

Example

-- Simulator value, not a panel value
fs2020_rpn("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fs2020_rpn.png

fs2020_variable_subscribe

Simulation Instrument Studio 1

Overloads

fs2020_variable_subscribe(variable, unit, callback_function)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1 .. nvariableStringReference to a variable from Flight Simulator 2020. Use prefix 'L:' for LVARS, see example below
2 .. nunitStringUnit of the variable, can be found with the variable. Different units can be used for different variables. For example Hours, Knots and RPM
lastcallback_functionFunctionThe function to call when new data is available

Example

fs2020_variable_subscribe("INDICATED ALTITUDE", "Feet", function(ft)
    txt_set(alt, tostring(math.floor(ft)))
end)
Photo slot: shots/fs2020_variable_subscribe.png

fs2020_variable_write

Simulation Instrument Studio 1

Overloads

fs2020_variable_write(variable, unit, value)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1variableStringReference to a variable from Flight Simulator 2020
2unitStringUnit of the variable, can be found with the variable. Different units can be used for different variables. For example Hours, Knots and RPM.
3valueNumberThe value to be written

Example

-- Simulator value, not a panel value
fs2020_variable_write("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fs2020_variable_write.png

fs2024_connected

Simulation Instrument Studio 1

Overloads

fs2024_connected()

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1connectedBooleanTrue is connected, otherwise false

Example

-- Simulator value, not a panel value
fs2024_connected("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fs2024_connected.png

fs2024_event

Simulation Instrument Studio 1

Overloads

fs2024_event(event)
fs2024_event(event, type, value)
fs2024_event(event, value)
fs2024_event(event, value, value_2)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1eventStringReference to an event from Flight Simulator 2020. Use 'H:' prefix for H events, see example below.
2typeString(Optional) Data type, can be INT, FLOAT, DOUBLE, BOOL or STRING.
3valueNumber(Optional) Send a value with the event. Some events support setting a value.
4value_2Number(Optional) Send a value with the event. Some events support setting a value.

Example

-- Simulator value, not a panel value
fs2024_event("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fs2024_event.png

fs2024_event_subscribe

Simulation Instrument Studio 1

Overloads

fs2024_event_subscribe(event, callback)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1eventStringReference to the FS2024 event
2callbackFunctionThe function to call when a new event has been sent within FS2024

Example

-- Simulator value, not a panel value
fs2024_event_subscribe("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fs2024_event_subscribe.png

fs2024_rpn

Simulation Instrument Studio 1

Overloads

fs2024_rpn(rpn_script, callback)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1rpn_scriptStringThe RPN script to execute within FS2024.
2callbackFunction(Optional) Return value from the executed RPN script. Three arguments are given, first is integer, second is float and third is string. Note that these arguments are nil when script could not be executed. Make sure to nil check in your callback.

Example

-- Simulator value, not a panel value
fs2024_rpn("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fs2024_rpn.png

fs2024_variable_subscribe

Simulation Instrument Studio 1

Overloads

fs2024_variable_subscribe(variable, unit, callback_function)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1 .. nvariableStringReference to a variable from Flight Simulator 2024. Use prefix 'L:' for LVARS, see example below
2 .. nunitStringUnit of the variable, can be found with the variable. Different units can be used for different variables. For example Hours, Knots and RPM
lastcallback_functionFunctionThe function to call when new data is available

Example

fs2024_variable_subscribe("INDICATED ALTITUDE", "Feet", function(ft)
    txt_set(alt, tostring(math.floor(ft)))
end)
Photo slot: shots/fs2024_variable_subscribe.png

fs2024_variable_write

Simulation Instrument Studio 1

Overloads

fs2024_variable_write(variable, unit, value)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1variableStringReference to a variable from Flight Simulator 2024
2unitStringUnit of the variable, can be found with the variable. Different units can be used for different variables. For example Hours, Knots and RPM.
3valueNumberThe value to be written

Example

-- Simulator value, not a panel value
fs2024_variable_write("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fs2024_variable_write.png

fsx_connected

Simulation Instrument Studio 1

Overloads

fsx_connected()

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1connectedBooleanTrue is connected, otherwise false

Example

-- Simulator value
fsx_connected("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fsx_connected.png

fsx_event

Simulation Instrument Studio 1

Overloads

fsx_event(event,value)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1eventStringReference to an event from Flight Simulator X or Prepar3D
2valueNumber(Optional) Send a value with the event. Some events support setting a value.

Example

-- Simulator value
fsx_event("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fsx_event.png

fsx_variable_subscribe

Simulation Instrument Studio 1

Overloads

fsx_variable_subscribe(variable, unit, callback_function)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1 .. nvariableStringReference to a variable from Flight Simulator X or Prepar3D
2 .. nunitStringUnit of the variable, can be found with the variable. Different units can be used for different variables. For example Hours, Knots and RPM (look here for FSX units and here for Prepar3D)
lastcallback_functionFunctionThe function to call when new data is available

Example

fsx_variable_subscribe("INDICATED ALTITUDE", "Feet", function(ft)
    txt_set(alt, tostring(math.floor(ft)))
end)
Photo slot: shots/fsx_variable_subscribe.png

fsx_variable_write

Simulation Instrument Studio 1

Overloads

fsx_variable_write(variable, unit, value)

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1variableStringReference to a variable from Flight Simulator X or Prepar3D
2unitStringUnit of the variable, can be found with the variable. Different units can be used for different variables. For example Hours, Knots and RPM
3valueNumberThe value to be written

Example

-- Simulator value
fsx_variable_write("INDICATED ALTITUDE", "Feet")
Photo slot: shots/fsx_variable_write.png

p3d_connected

Simulation Instrument Studio 1

Overloads

p3d_connected()

A simulator call. Connection, variables, and events for that sim.

Parameters

#NameTypeDescription
1connectedBooleanTrue is connected, otherwise false

Example

-- Simulator value
p3d_connected("INDICATED ALTITUDE", "Feet")
Photo slot: shots/p3d_connected.png