1
0
mirror of synced 2024-11-22 10:03:51 +00:00

Implemented autopilot.lua

This commit is contained in:
Mark van Renswoude 2017-06-10 10:19:55 +02:00
parent fd0202536c
commit 37f3683ceb

View File

@ -1,43 +1,45 @@
local strings = require './lib/strings' local strings = require './lib/strings'
-- Autopilot master
-- Autopilot altitude
-- Autopilot approach
-- Autopilot backcourse
-- Autopilot heading
-- Autopilot nav
local function RegisterAutopilotFunction(functionUid, functionDisplayName, variableName)
RegisterFunction(
{
uid = functionUid,
category = strings.Category.FSX.AutoPilot,
displayName = functionDisplayName,
states = {
notAvailable = { displayName = 'Not available', default = LEDColor.Off, order = 1 },
on = { displayName = 'On', default = LEDColor.Green, order = 2 },
off = { displayName = 'Off', default = LEDColor.Red, order = 3 }
}
},
function(context)
SetState(context, 'notAvailable')
-- Autopilot airspeed OnSimConnect(context,
RegisterFunction( {
{ autoPilotAvailable = { variable = 'AUTOPILOT AVAILABLE', type = SimConnectDataType.Bool },
uid = 'autoPilotAirspeed', autoPilotState = { variable = variableName, type = SimConnectDataType.Bool }
category = strings.Category.FSX.AutoPilot, },
displayName = 'Autopilot airspeed', function(context, data)
states = { if data.autoPilotAvailable then
notAvailable = { displayName = 'Not available', default = LEDColor.Off, order = 1 }, if data.autoPilotState then
on = { displayName = 'On', default = LEDColor.Green, order = 2 }, SetState(context, 'on')
off = { displayName = 'Off', default = LEDColor.Red, order = 3 } else
} SetState(context, 'off')
}, end
function(context)
SetState(context, 'notAvailable')
OnSimConnect(context,
{
autoPilotAvailable = { variable = 'AUTOPILOT AVAILABLE', type = SimConnectDataType.Bool },
autoPilotAirspeed = { variable = 'AUTOPILOT AIRSPEED HOLD', type = SimConnectDataType.Bool }
},
function(context, data)
if data.autoPilotAvailable then
if data.autoPilotAirspeed then
SetState(context, 'on')
else else
SetState(context, 'off') SetState(context, 'notAvailable')
end end
else end)
SetState(context, 'notAvailable') end
end )
end) end
end
) RegisterAutopilotFunction('autoPilotMaster', 'Autopilot master', 'AUTOPILOT MASTER')
RegisterAutopilotFunction('autoPilotHeading', 'Autopilot heading', 'AUTOPILOT HEADING LOCK')
RegisterAutopilotFunction('autoPilotApproach', 'Autopilot approach', 'AUTOPILOT APPROACH HOLD')
RegisterAutopilotFunction('autoPilotBackcourse', 'Autopilot backcourse', 'AUTOPILOT BACKCOURSE HOLD')
RegisterAutopilotFunction('autoPilotAltitude', 'Autopilot heading', 'AUTOPILOT ALTITUDE LOCK')
RegisterAutopilotFunction('autoPilotNav', 'Autopilot nav', 'AUTOPILOT NAV1 LOCK')
RegisterAutopilotFunction('autoPilotAirspeed', 'Autopilot airspeed', 'AUTOPILOT AIRSPEED HOLD')