The following Lua script turns on the engine anti ice functions.

  1. Open the Lua Console.
  2. Create a new Lua script and call it engine_anti_ice_on
  3. A text editor should have opened with a blank Lua script file. Copy and paste the following into the text editor and then save the file:

    if (getkvar("DATA_FWDOH_ICE_SWITCH_ENG_ANTI_ICE_LEFT") == 0) then
        sendevt("EVT_OH_ICE_ENGINE_ANTIICE_1", MOUSE_LEFTSINGLE)
    end

    if (getkvar("DATA_FWDOH_ICE_SWITCH_ENG_ANTI_ICE_RIGHT") == 0) then
        sendevt("EVT_OH_ICE_ENGINE_ANTIICE_2", MOUSE_LEFTSINGLE)
    end

    -- Allow time for the NGX to complete the previous sendevts before querying the switch state values
    sleep(75)

    setbvar("Bespoke Var 0", getkvar("DATA_FWDOH_ICE_SWITCH_ENG_ANTI_ICE_LEFT") & getkvar ("DATA_FWDOH_ICE_SWITCH_ENG_ANTI_ICE_RIGHT"))

If error messages appear when running the above script in the Lua console, then its likely that your text editor understands HTML and has accepted the HTML code used to build this web page as well as the text above. To fix, simply copy and paste the above Lua code into Notepad (which will strip away any HTML code) and then copy and paste the Lua code from Notepad over the top of your previous pasted Lua Code from step 3.

The  "if (getkvar( ...." statements read the state of the engine anti ice switches and if they are off (equal zero), then the sendevt functions are executed which turn the anti ice switches on.

The sleep function allows time for the NGX to process the Events.

Finally the setbvar function sets the Bespoke variable Bespoke Var 0 to the state of both switches. The state uses a bitwise And operator (&) to determine if they are both on. I.e. both the getkvar functions would have to return 1 for Bespoke Var 0 to equal 1 (ON), otherwise it will be set to 0 (OFF) since at least one of the engine anti-ice switches is set of off.

The Bespoke variable Bespoke Var 0 could then be assigned to Light Data within GIT so that the state of the engine anti ice could be indicated on some GoFlight module. The Light Action should be set to ON and the Light Value should be set to 1.

If Bespoke variables are used for LED's or displays, it is recommend that you add the relevant code to global_aircraft.lua to get the current state of the switches when the aircraft first loads. It only needs to run once and in the example above this would be:

setbvar("Bespoke Var 0", getkvar("DATA_FWDOH_ICE_SWITCH_ENG_ANTI_ICE_LEFT") & getkvar ("DATA_FWDOH_ICE_SWITCH_ENG_ANTI_ICE_RIGHT"))

For completeness, here is the Lua script to turn the engine anti-ice functions off:

if (getkvar("DATA_FWDOH_ICE_SWITCH_ENG_ANTI_ICE_LEFT") == 1) then
    sendevt("EVT_OH_ICE_ENGINE_ANTIICE_1", MOUSE_LEFTSINGLE)
end

if (getkvar("DATA_FWDOH_ICE_SWITCH_ENG_ANTI_ICE_RIGHT") == 1) then
    sendevt("EVT_OH_ICE_ENGINE_ANTIICE_2", MOUSE_LEFTSINGLE)
end

-- Allow time for the NGX to complete the previous sendevts before querying the switch state values
sleep(75)

setbvar("Bespoke Var 0", getkvar("DATA_FWDOH_ICE_SWITCH_ENG_ANTI_ICE_LEFT") & getkvar ("DATA_FWDOH_ICE_SWITCH_ENG_ANTI_ICE_RIGHT"))

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.