1
0
mirror of synced 2024-11-05 02:59:16 +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,19 +1,12 @@
local strings = require './lib/strings'
-- Autopilot master
-- Autopilot altitude
-- Autopilot approach
-- Autopilot backcourse
-- Autopilot heading
-- Autopilot nav
-- Autopilot airspeed
RegisterFunction(
local function RegisterAutopilotFunction(functionUid, functionDisplayName, variableName)
RegisterFunction(
{
uid = 'autoPilotAirspeed',
uid = functionUid,
category = strings.Category.FSX.AutoPilot,
displayName = 'Autopilot airspeed',
displayName = functionDisplayName,
states = {
notAvailable = { displayName = 'Not available', default = LEDColor.Off, order = 1 },
on = { displayName = 'On', default = LEDColor.Green, order = 2 },
@ -26,11 +19,11 @@ RegisterFunction(
OnSimConnect(context,
{
autoPilotAvailable = { variable = 'AUTOPILOT AVAILABLE', type = SimConnectDataType.Bool },
autoPilotAirspeed = { variable = 'AUTOPILOT AIRSPEED HOLD', type = SimConnectDataType.Bool }
autoPilotState = { variable = variableName, type = SimConnectDataType.Bool }
},
function(context, data)
if data.autoPilotAvailable then
if data.autoPilotAirspeed then
if data.autoPilotState then
SetState(context, 'on')
else
SetState(context, 'off')
@ -40,4 +33,13 @@ RegisterFunction(
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')