The following Lua script turns on the aircrafts runway turnoff lights.

  1. Open the Lua Console.
  2. Create a new Lua script and call it runway_turnoff_lights_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("Runway_1_Light_Switch_Status") == 0) then
        sendevt("KEY_COMMAND_IFLY744_GENERAL_RUNWAY_LIGHT_1_ON", 0)
    end
    if (getkvar("Runway_2_Light_Switch_Status") == 0) then
        sendevt("KEY_COMMAND_IFLY744_GENERAL_RUNWAY_LIGHT_2_ON", 0)
    end

    -- wait for the events to complete before reading the switch states
    sleep(75)

    setbvar("BespokeVar0", getkvar("Runway_1_Light_Switch_Status") & getkvar("Runway_2_Light_Switch_Status"))

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 runway turnoff light switches and if they are off (equal zero), then the sendevt functions are executed which turn the runway turnoff light switches on.

The sleep functions allows time for the 747 to process the Events before querying the switch state.

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 runway turnoff light switches is set of off.

The Bespoke variable Bespoke Var 0 could then be assigned to a Component LED so that state of the runway turnoff lights could be indicated on your Device Panel. The Data Action should be set to ON and the Custom Value should be set to 1.

If Bespoke variables are used for LED's or Display Components, 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("BespokeVar0", getkvar("Runway_1_Light_Switch_Status") & getkvar("Runway_2_Light_Switch_Status"))

For completeness, here is the Lua script to turn the runway turnoff lights off:

if (getkvar("Runway_1_Light_Switch_Status") == 1) then
    sendevt("KEY_COMMAND_IFLY744_GENERAL_RUNWAY_LIGHT_1_OFF", 0)
end
if (getkvar("Runway_2_Light_Switch_Status") == 1) then
    sendevt("KEY_COMMAND_IFLY744_GENERAL_RUNWAY_LIGHT_2_OFF", 0)
end

-- wait for the events to complete before reading the switch states
sleep(75)

setbvar("BespokeVar0", getkvar("Runway_1_Light_Switch_Status") & getkvar("Runway_2_Light_Switch_Status"))

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.