diff --git a/G940LEDControl/Scripts/FSX/engines.lua b/G940LEDControl/Scripts/FSX/engines.lua index a534efe..0a540df 100644 --- a/G940LEDControl/Scripts/FSX/engines.lua +++ b/G940LEDControl/Scripts/FSX/engines.lua @@ -112,9 +112,9 @@ RegisterFunction( elseif runningCount == 0 then SetState(context, 'allOff') elseif runningCount == data.engineCount then - SetState(context, 'partiallyRunning') - else SetState(context, 'allRunning') + else + SetState(context, 'partiallyRunning') end else SetState(context, 'noEngines') diff --git a/G940LEDControl/Units/FSXLEDFunctionProvider.pas b/G940LEDControl/Units/FSXLEDFunctionProvider.pas index 64ec9d3..d0306ef 100644 --- a/G940LEDControl/Units/FSXLEDFunctionProvider.pas +++ b/G940LEDControl/Units/FSXLEDFunctionProvider.pas @@ -71,9 +71,11 @@ type TFSXLEDFunctionWorker = class(TCustomLuaLEDFunctionWorker) private FDefinitions: TList; + FSimConnect: IFSXSimConnect; protected property Definitions: TList read FDefinitions; protected + function GetSimConnect: IFSXSimConnect; procedure AddDefinition(ADefinition: IFSXSimConnectDefinition; ADataHandler: IFSXSimConnectDataHandler); procedure HandleData(AData: Pointer); virtual; abstract; @@ -434,13 +436,22 @@ begin end; +function TFSXLEDFunctionWorker.GetSimConnect: IFSXSimConnect; +begin + if not Assigned(FSimConnect) then + FSimConnect := (Provider as TFSXLEDFunctionProvider).GetSimConnect; + + Result := FSimConnect; +end; + + procedure TFSXLEDFunctionWorker.AddDefinition(ADefinition: IFSXSimConnectDefinition; ADataHandler: IFSXSimConnectDataHandler); var definition: TFSXDefinition; begin definition.DataHandler := ADataHandler; - definition.ID := (Provider as TFSXLEDFunctionProvider).GetSimConnect.AddDefinition(ADefinition, ADataHandler); + definition.ID := GetSimConnect.AddDefinition(ADefinition, ADataHandler); Definitions.Add(definition); end;