Difference between revisions of "Request callback"

From Sim Innovations Wiki
Jump to navigation Jump to search
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:


'''request_callback''' is used to force a callback on a given data subscription (X-plane, FSX, FS2, IIC or external sources)
'''request_callback''' is used to force a callback on a given data subscription (X-plane, FSX, FS2, IIC or external sources)
{{tip|The callback will only be called when there is a connection with the given flight simulator or data source.}}


== Return value ==  
== Return value ==  
Line 27: Line 29:
   -- subscribe X-plane datarefs on the AirBus
   -- subscribe X-plane datarefs on the AirBus
   xpl_dataref_subscribe("sim/cockpit2/gauges/indicators/altitude_ft_pilot", "FLOAT", new_altitude_callback)
   xpl_dataref_subscribe("sim/cockpit2/gauges/indicators/altitude_ft_pilot", "FLOAT", new_altitude_callback)


   -- Force a callback. The 'new_altitude_callback' function will be called here with its current arguments.
   -- Force a callback. The 'new_altitude_callback' function will be called here with its current arguments.
   request_callback(new_altitude_callback)
   request_callback(new_altitude_callback)
</source >
</source >

Revision as of 13:30, 5 February 2019

Description

request_callback(callback_function)

request_callback is used to force a callback on a given data subscription (X-plane, FSX, FS2, IIC or external sources)

Info The callback will only be called when there is a connection with the given flight simulator or data source.

Return value

This function won't return any value.

Arguments

# Argument Type Description
1 function_callback String The callback function that should be updated

Example

-- This function will be called when new data is available from X-plane
  function new_altitude_callback(altitude)
    print("New altitude: " .. altitude)
  end

  -- subscribe X-plane datarefs on the AirBus
  xpl_dataref_subscribe("sim/cockpit2/gauges/indicators/altitude_ft_pilot", "FLOAT", new_altitude_callback)

  -- Force a callback. The 'new_altitude_callback' function will be called here with its current arguments.
  request_callback(new_altitude_callback)