LUA Panels

Settings

LUA Macros Address

For example http://localhost:12345/ (must begin with http:// and end with slash)

Test connection

Available panels

LUA script

http_server.lua
-- http server
lmc_http_server(12345, function(url)
  if(string.sub(url,2,12) == 'init_global') then
    print('HTTP Panel Init')
    lmc_xpl_command('sim/lights/landing_lights_off')
    lmc_xpl_command('sim/lights/taxi_lights_off')
    lmc_xpl_command('sim/lights/strobe_lights_off')
    lmc_xpl_command('sim/lights/beacon_lights_off')
    lmc_xpl_command('sim/lights/nav_lights_off')
  elseif(string.sub(url,2,12) == 'init_lights') then
    print('HTTP Panel Init / Lights')
    lmc_xpl_command('sim/lights/landing_lights_off')
    lmc_xpl_command('sim/lights/taxi_lights_off')
    lmc_xpl_command('sim/lights/strobe_lights_off')
    lmc_xpl_command('sim/lights/beacon_lights_off')
    lmc_xpl_command('sim/lights/nav_lights_off')
  elseif(string.sub(url,2,18) == 'landing_lights_on') then
    lmc_xpl_command('sim/lights/landing_lights_on')
  elseif(string.sub(url,2,19) == 'landing_lights_off') then
    lmc_xpl_command('sim/lights/landing_lights_off')
  elseif(string.sub(url,2,14) == 'nav_lights_on') then
    lmc_xpl_command('sim/lights/nav_lights_on')
  elseif(string.sub(url,2,15) == 'nav_lights_off') then
    lmc_xpl_command('sim/lights/nav_lights_off')
  elseif(string.sub(url,2,15) == 'taxi_lights_on') then
    lmc_xpl_command('sim/lights/taxi_lights_on')
  elseif(string.sub(url,2,16) == 'taxi_lights_off') then
    lmc_xpl_command('sim/lights/taxi_lights_off')
  elseif(string.sub(url,2,17) == 'strobe_lights_on') then
    lmc_xpl_command('sim/lights/strobe_lights_on')
  elseif(string.sub(url,2,18) == 'strobe_lights_off') then
    lmc_xpl_command('sim/lights/strobe_lights_off')
  elseif(string.sub(url,2,17) == 'beacon_lights_on') then
    lmc_xpl_command('sim/lights/beacon_lights_on')
  elseif(string.sub(url,2,18) == 'beacon_lights_off') then
    lmc_xpl_command('sim/lights/beacon_lights_off')
  elseif(string.sub(url,2,9) == 'get_data') then
    msg = '{"HDG" : ' .. lmc_get_xpl_variable('sim/flightmodel/position/psi')
    msg = msg .. ', "SPD" : ' .. lmc_get_xpl_variable('sim/flightmodel/position/indicated_airspeed')
    msg = msg .. ', "LAT" : ' .. lmc_get_xpl_variable('sim/flightmodel/position/latitude')
    msg = msg .. ', "LON" : ' .. lmc_get_xpl_variable('sim/flightmodel/position/longitude')
    msg = msg .. '}'
    print('Get data')
    print(msg)
    return msg, 'application/json'
  elseif(url == '/favicon.ico') then
  else
    print('Callback for ' .. url)
  end
end)