1
0
mirror of synced 2024-11-22 01:53:50 +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'
-- 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
RegisterFunction(
{
uid = 'autoPilotAirspeed',
category = strings.Category.FSX.AutoPilot,
displayName = 'Autopilot airspeed',
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')
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')
OnSimConnect(context,
{
autoPilotAvailable = { variable = 'AUTOPILOT AVAILABLE', type = SimConnectDataType.Bool },
autoPilotState = { variable = variableName, type = SimConnectDataType.Bool }
},
function(context, data)
if data.autoPilotAvailable then
if data.autoPilotState then
SetState(context, 'on')
else
SetState(context, 'off')
end
else
SetState(context, 'off')
SetState(context, 'notAvailable')
end
else
SetState(context, 'notAvailable')
end
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')