Simulation Instruments

Home›All functions›Instrument

Instrument

Simulation Instrument Studio 1

si_command

Simulation Instrument Studio 1

Overloads

si_command(command_name)
si_command(command_name, type)

An inter-instrument value. Other instruments on this panel can read and write it.

Parameters

#NameTypeDescription
1command_nameStringReference to a global command
2typeString(Optional) Can be 'BEGIN', 'ONCE' or 'END'.

Example

-- A value other instruments on this panel can read
si_command("selected_altitude", 3000)
Photo slot: shots/si_command.png

si_command_subscribe

Simulation Instrument Studio 1

Overloads

si_command_subscribe(command_name,callback_function)

An inter-instrument value. Other instruments on this panel can read and write it.

Parameters

#NameTypeDescription
1command_nameStringReference to a global variable
2callback_functionFunctionThe function to call when a new command has been sent

Example

-- A value other instruments on this panel can read
si_command_subscribe("selected_altitude", 3000)
Photo slot: shots/si_command_subscribe.png

si_variable_create

Simulation Instrument Studio 1

Overloads

si_variable_create(variable, type, initial_value)

An inter-instrument value. Other instruments on this panel can read and write it.

Parameters

#NameTypeDescription
1variableStringName of the variable
2typeStringData type of the variable, can be INT, FLOAT, DOUBLE, BYTE, BOOL, STRING, INT[n], FLOAT[n], DOUBLE[n] or BYTE[n]
3initial_valueObjectSet the initial value for this variable.

Example

-- A value other instruments on this panel can read
si_variable_create("selected_altitude", 3000)
Photo slot: shots/si_variable_create.png

si_variable_subscribe

Simulation Instrument Studio 1

Overloads

si_variable_subscribe(variable,type,...,callback_function)

An inter-instrument value. Other instruments on this panel can read and write it.

Parameters

#NameTypeDescription
1 .. nvariableStringReference to a SI variable
2 .. nunitStringData type of the variable, can be INT, FLOAT, DOUBLE, BYTE, BOOL, STRING, INT[n], FLOAT[n], DOUBLE[n] or BYTE[n]
lastcallback_functionFunctionThe function to call when new data is available

Example

-- A value other instruments on this panel can read
si_variable_subscribe("selected_altitude", 3000)
Photo slot: shots/si_variable_subscribe.png

si_variable_write

Simulation Instrument Studio 1

Overloads

si_variable_write(var_id, value)

An inter-instrument value. Other instruments on this panel can read and write it.

Parameters

#NameTypeDescription
1var_idStringReference to a global variable. Can be obtained using si_variable_create.
2valueObjectThe new value to write. You have to obay to the data type you have chosen in the si_variable_create function. It is not allowed to change type at runtime.

Example

-- A value other instruments on this panel can read
si_variable_write("selected_altitude", 3000)
Photo slot: shots/si_variable_write.png

ext_command

Simulation Instrument Studio 1

Overloads

ext_command(source_tag, event, value)

An external data call. It publishes and subscribes outside the simulator.

Parameters

#NameTypeDescription
1source_tagStringThe data source tag. The source tag can be configured in the settings part of Studio.
2eventStringCommand name in the external source
3valueNumber(Optional) Send a value with the command. Some commands support setting a value.

Example

-- A value from outside the simulator
ext_command("efis", "altitude")
Photo slot: shots/ext_command.png

ext_command_subscribe

Simulation Instrument Studio 1

Overloads

ext_command_subscribe(command_name, callback_function)

An external data call. It publishes and subscribes outside the simulator.

Parameters

#NameTypeDescription
1command_nameStringReference to the command
2callback_functionFunctionThe function to call when a new command has been sent

Example

-- A value from outside the simulator
ext_command_subscribe("efis", "altitude")
Photo slot: shots/ext_command_subscribe.png

ext_connected

Simulation Instrument Studio 1

Overloads

ext_connected(source_tag)

An external data call. It publishes and subscribes outside the simulator.

Parameters

#NameTypeDescription
1source_tagStringThe data source tag. The source tag can be configured in the settings part of Studio.

Example

-- A value from outside the simulator
ext_connected("efis", "altitude")
Photo slot: shots/ext_connected.png

ext_variable_subscribe

Simulation Instrument Studio 1

Overloads

ext_variable_subscribe(source_tag, variable, data_type, ..., callback_function)

An external data call. It publishes and subscribes outside the simulator.

Parameters

#NameTypeDescription
1source_tagStringThe data source tag. The source tag can be configured in the settings part of Studio
2 .. nvariableStringReference to a panel variable
3 .. ndata_typeStringData type of the variable, can be INT, FLOAT, DOUBLE, BYTE, BOOL, STRING, INT[n], FLOAT[n], DOUBLE[n] or BYTE[n]
lastsource_tagStringThe data source tag. The source tag can be configured in the settings part of Studio

Example

-- A value from outside the simulator
ext_variable_subscribe("efis", "altitude")
Photo slot: shots/ext_variable_subscribe.png

ext_variable_write

Simulation Instrument Studio 1

Overloads

ext_variable_write(source_tag,variable, unit, value)

An external data call. It publishes and subscribes outside the simulator.

Parameters

#NameTypeDescription
1source_tagStringThe data source tag. The source tag can be configured in the settings part of Studio
2variableStringReference to a variable on the external source
3typeStringData type of the variable, can be INT, FLOAT, DOUBLE, INT[n], FLOAT[n], DOUBLE[n] or BYTE[n]
4valueNumberThe value to be written

Example

-- A value from outside the simulator
ext_variable_write("efis", "altitude")
Photo slot: shots/ext_variable_write.png

layer_add

Simulation Instrument Studio 1

Overloads

layer_add(z_order, callback)
layer_add(z_order, callback, input_event_callback)
layer_add(z_order, x, y, w, h, callback)
layer_add(z_order, x, y, w, h, callback, input_event_callback)

A layer groups drawing and mouse handling inside one instrument.

Parameters

#NameTypeDescription
1z_orderNumberThe Z order. Lowest value is drawn at the back, highest is drawn on the top. The panel/instrument root lua is always drawn at order 0.
2xNumber(Optional) X position in pixels of the layer
3yNumber(Optional) Y position in pixels of the layer
4widthNumber(Optional) Width in pixels of the layer
5heightNumber(Optional) Height in pixels of the layer
6callbackFunctionCallback function. Add GUI nodes (such as img_add, txt_add. etc. etc.) you create within this function will be added to this layer.
7input_event_callbackFunction(Optional) Callback where input events (mouse & touch) are sent. Callback arguments are id, x, y and finger_id.

Example

-- A click layer over the Kollsman knob
layer_add(80, 170, 80, 40, function()
    log("kollsman")
end)
Photo slot: shots/layer_add.png

layer_mouse_cursor

Simulation Instrument Studio 1

Overloads

layer_mouse_cursor(layer_id, cursor)

A layer groups drawing and mouse handling inside one instrument.

Parameters

#NameTypeDescription
1layer_idIDLayer identifier. This can be obtained by calling function layer_add.
2cursorStringThe cursor type, see the list below. It is also possible to add you own custom cursor proving your own from resources folder, this image must be 32x32 32-bit PNG file.

Cursors

NameLooks like
NONENo cursor.
POINTERArrow.
HANDHand.
CWClockwise.
CCWCounterclockwise.
GRABGrab.
LEFTArrow left.
RIGHTArrow right.
TOPArrow up.
BOTTOMArrow down.

A 32×32 PNG in the instrument resources folder is also accepted.

Example

layer_mouse_cursor(knob_layer, "CW")

Example: a fixed cursor, and one that follows the mouse

layer_mouse_cursor(knob_layer, "CW")

function on_move(id, x, y)
    if x < 80 then
        layer_mouse_cursor(knob_layer, "LEFT")
    elseif x > 160 then
        layer_mouse_cursor(knob_layer, "RIGHT")
    else
        layer_mouse_cursor(knob_layer, "HAND")
    end
end
Photo slot: shots/layer_mouse_cursor.png

instrument_add

Simulation Instrument Studio 1

Overloads

instrument_add(uuid, plugin_uuid, x, y, width, height)
instrument_add(uuid, plugin_uuid, x, y, width, height, callback)
instrument_add(uuid, plugin_uuid, x, y, width, height, user_properties, callback)
instrument_add(uuid, plugin_uuid, x, y, width, height, user_properties, hw_properties, callback)

Adds or reads another instrument from this one.

Parameters

#NameTypeDescription
1uuidUUIDMake sure each of your instruments within this panel gets a unique uuid. You can generate an UUID here.
2plugin_uuidStringThe UUID string for the instrument plugin.
3xNumberThis is the most left point of the canvas where your instrument should be shown.
4yNumberThis is the most top point of the canvas where your instrument should be shown.
5widthNumberThe instrument width on the canvas.
6heightNumberThe instrument height on the canvas.
7user_propertiesTable(Optional) Instrument user properties.
8hw_propertiesTable(Optional) Instrument hardware properties.
9callbackFunction(Optional) Callback is called when the instrument is created.

Example

-- Create the instrument, first argument is your own generated UUID, second argument is the plugin UUID
instrument_add("5ed42efb-9e53-42a0-92ad-e2b0730e2306", "dc979f8e-ab07-4cb0-b755-eac3b9fbd601", 0, 300, 200, 200)
Photo slot: shots/instrument_add.png

instrument_get

Simulation Instrument Studio 1

Overloads

instrument_get(uuid)
instrument_get(uuid, offset)

Adds or reads another instrument from this one.

Parameters

#NameTypeDescription
1uuidStringThe UUID string for the instrument.
2offsetNumber(Optional) Offset when multiple instruments of the same type are part of the panel.

Example

id = instrument_get("fd2f89a1-59ec-416f-8f28-e5b8bf4c1cbc")

if id ~= nil then
  -- Make the instrument invisible
  visible(id, false)
else
  print("Could not find instrument")
end
Photo slot: shots/instrument_get.png