Variable subscribe

From Sim Innovations Wiki
Revision as of 16:06, 12 August 2020 by Admin (talk | contribs) (→‎Arguments)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search



variable_subscribe is used to subscribe to more different data sources (such as X-plane, FSX and AM varables).

Return value

This function won't return any value.


# Argument Type Description
1 .. n source String Can be "XPLANE", "FS2020", "FSX", "PREPAR3D", "FS2" or "SI"
2 .. n variable_name String The name of the variable. This name depends on the source used.
3 .. n data_type String Data type of the variable. This depends on the source used. In general it can be INT,FLOAT,DOUBLE,INT[n],FLOAT[n],DOUBLE[n], BYTE[n] or STRING.
last callback_function String The function to call when new data is available


-- Note that the order in which the variables are given to the variable_subscribe function determines the order in which the variables will enter this function

-- In our case 
-- "sim/cockpit2/gauges/indicators/altitude_ft_pilot" maps to "altitude"
-- "TIME ZULU" maps to "time_seconds"
-- "MY_CUSTOM_VARIABLE" maps to "my_custom_variable"
function callback_function(altitude, time_seconds, my_custom_variable)
  print("Altitude from X-plane=" .. altitude)
  print("Time seconds from FSX=" .. time_seconds)
  print("My Custom variable from AM=" .. my_custom_variable)

-- multi subscribe
variable_subscribe("XPLANE", "sim/cockpit2/gauges/indicators/altitude_ft_pilot",  "FLOAT",
                   "FSX", "TIME ZULU", "Seconds",
                   "SI", "MY_CUSTOM_VARIABLE", "INT", callback_function)