The following details extensions made to the Lua implementation for the specific purpose of interacting with GIT and the flight simulator. You can use them in Lua script files to perform useful functions.
Note that the extensions (functions) are case sensitive as is all Lua scripting code.
sendevt
USAGE: sendevt( string eventName, int eventData )
PURPOSE: Sends an Event and any associated data to the flight simulator.
EXAMPLE: sendevt("KEY_ANTI_ICE_SET_ENG1", 1)
EXAMPLE EXPLAINED: This will send the Simconnect Event KEY_ANTI_ICE_SET_ENG1 to the flight simulator with a data value of 1. The event sets the anti ice function of engine 1. This particular Event requires a data value (most do not and can be set to 0). The data value of 1 means "turn it on" and a value of 0 means "turn if off".
INFO:
- The eventName can be a Simconnect Event (a full list with explanations is here), a Mouse Click Event or an SDK Event (PMDG and iFly aircraft only).
- Only Simconnect events will accept negative eventData which is usually used for axis values.
- For PMDG aircraft and for Mouse Click Events, the eventData indicates the mouse action to be used against the event (i.e. what you would do in the Virtual Cockpit). and should be one of the following:
- MOUSE_RIGHTSINGLE
- MOUSE_LEFTSINGLE
- MOUSE_MIDDLESINGLE
- MOUSE_RIGHTDOUBLE
- MOUSE_LEFTDOUBLE
- MOUSE_MIDDLEDOUBLE
- MOUSE_RIGHTDRAG
- MOUSE_LEFTDRAG
- MOUSE_MIDDLEDRAG
- MOUSE_MOVE
- MOUSE_DOWN_REPEAT
- MOUSE_RIGHTRELEASE
- MOUSE_MIDDLERELEASE
- MOUSE_LEFTRELEASE
- MOUSE_WHEEL_FLIP
- MOUSE_WHEEL_SKIP
- MOUSE_WHEEL_UP
- MOUSE_WHEEL_DOWN
- MOUSE_MOVE_REPEAT
- MOUSE_LEAVE
- E.g. sendevt("EVT_OH_ICE_ENGINE_ANTIICE_2", MOUSE_LEFTSINGLE)
sendcevt (MS FS2020 Only)
USAGE: sendcevt( string eventName )
PURPOSE: Sends an Client/Custom Event to the flight simulator.
EXAMPLE: sendcevt("H:A320_Neo_CDU_1_BTN_1)
EXAMPLE EXPLAINED: This will send the HTML Event Event A320_Neo_CDU_1_BTN_1 to the flight simulator. The event simulates the pressing of button 1 on the CDU of the A320. Note the H: in front of the Event name, indicating its a HTML Event.
INFO:
- The eventName can be any known Event.
- If the Event is a HTML event, precede the Event name with H:
- If the Event is a SimConnect event, precede the Event name with K:
getsvar
USAGE: getsvar( string variableName, enum unitType )
PURPOSE: Gets the value of a Simconnect variable in the format of the chosen unit.
EXAMPLE: eng2Press = getsvar("GENERAL ENG FUEL PRESSURE:2", "Psi")
EXAMPLE EXPLAINED: This will get the engine pressure of engine number 2 in Pounds Per Square Inch (Psi) and assign it to the local Lua variable "eng2Press".
INFO:
- The variableName must be a Simconnect variable. A full list of Simconnect variables along with explanations and unitType's can be found here.
- Use sendevt or setsvar to change the value of Simconnect variables where applicable.
setsvar (GIT for FS2020 only at the moment)
USAGE: setsvar( string variableName, float64 value )
PURPOSE: Sets the value of a Simconnect Variable.
EXAMPLE: setsvar("GENERAL ENG THROTTLE LEVER POSITION:1", 50)
EXAMPLE EXPLAINED: This will set the first engine throttle control lever to 50% or, in other words at the half way position.
- The variableName must be a Simconnect variable. A full list of Simconnect variables can be found here.
- Use getsvar to get the value of a Simconnect variable.
getbvar
USAGE: getbvar( string variableName )
PURPOSE: Gets the value of a Bespoke variable.
EXAMPLE: x = getbvar("Bespoke Var 10")
EXAMPLE EXPLAINED: This will get the value of Bespoke Var 10 and assign it to the local Lua variable "x".
INFO: The variableName can also be written without spaces e.g. "BespokeVar10".
setbvar
USAGE: setbvar( string variableName, int value )
PURPOSE: Sets the value of a Bespoke variable.
EXAMPLE: setbvar("Bespoke Var 3", 78.5)
EXAMPLE EXPLAINED: This will set the value of Bespoke Var 3 to 78.5.
INFO: The variableName can also be written without spaces e.g. "BespokeVar3".
getlvar
USAGE: getlvar( string variableName )
PURPOSE: Gets the value of a Local variable (LVar).
EXAMPLE: cdiState = getlvar("CDI Source Selected")
EXAMPLE EXPLAINED: This will get the Local variable value of CDI Source Selected and assign it to the local Lua variable cdiState.
INFO: Do not confuse Lvar local variables with a Lua local variables. Lvar's are variables within a specific aircraft in the flight simulator, where as Lua local variables exist within Lua and get destroyed when the Lua script ends.
setlvar
USAGE: setlvar( string variableName, float64 value )
PURPOSE: Sets the value of a Local Variable (LVar).
EXAMPLE: setlvar("CDI Source Selected", cdiState)
EXAMPLE EXPLAINED: This will set the Local Variable CDI Source Selected to the value contained in the local Lua variable "cdiState".
INFO: Do not confuse Lvar local variables with a Lua local variables. Lvar's are variables within a specific aircraft in the flight simulator, where as Lua local variables exist within Lua and get destroyed when the Lua script ends.
getkvar (Not available in GIT FS2020)
USAGE: getkvar( string variableName )
PURPOSE: Gets the value of an SDK Variable.
EXAMPLE: aiEng1 = getkvar("DATA_FWDOH_ICE_SWITCH_ENG_ANTI_ICE_LEFT")
EXAMPLE EXPLAINED: This will get the PMDG NGX SDK variable value of DATA_FWDOH_ICE_SWITCH_ENG_ANTI_ICE_LEFT and assign it the local Lua variable aiEng1.
INFO:
- This function can only be used with the PMDG NGX, 777, 747 and the iFly 737 and 747.
- Use sendevt to change the value of SDK variables where applicable. E.g. sendevt("EVT_OH_ICE_ENGINE_ANTIICE_1", MOUSE_LEFTSINGLE)
sendkey
USAGE: sendkey( string character, <enum keyFlag> )
PURPOSE: Sends a key press or combination of key presses to the flight simulator.
EXAMPLE: sendkey ( "L", CONTROL | SHIFT )
EXAMPLE EXPLAINED: This will send the key combination of Control, Shift and "L" to the flight simulator which will toggle the aircraft labels.
INFO:
- The character parameter can be any key from 0 through to 9 and A through to Z.
- The parameter keyFlag is optional, so sendkey( "p" ) is valid syntax.
- Use an empty string if just a keyFlag is to be sent e.g. sendkey( "", TAB)
- The keyFlag parameter can be combined with multiple keys by using the bitwise OR operator ( | ). e.g. sendkey ( "", SHIFT | TAB | SPACE )
- The keyFlag parameter can be any combination of the following:
- BACK
- TAB
- ENTER
- SHIFT
- CONTROL
- ALT
- PAUSE
- CAPSLOCK
- ESC
- SPACE
- PGUP
- PGDN
- END
- HOME
- UP
- DOWN
- LEFT
- RIGHT
- APPS
- PRTSCRN
- INSERT
- DEL
- NUMLOCK
- OEM102 (Either the angle bracket key or the backslash key on the RT 102-key keyboard)
- NUM0
- NUM1
- NUM2
- NUM3
- NUM4
- NUM5
- NUM6
- NUM7
- NUM8
- NUM9
- NUMMUL
- NUMADD
- NUMSUB
- NUMDEC
- NUMDIV
- F1
- F2
- F3
- F4
- F5
- F6
- F7
- F8
- F9
- F10
- F11
- F12
- SCROLL
- PLUS
- MINUS
- PERIOD
- COMMA
- OEM1 (For the US standard keyboard, the ';:' key)
- OEM2 (For the US standard keyboard, the '/?' key)
- OEM3 (For the US standard keyboard, the '`~' key)
- OEM4 (For the US standard keyboard, the '[{' key)
- OEM5 (For the US standard keyboard, the '\|' key)
- OEM6 (For the US standard keyboard, the ']}' key)
- OEM7 (For the US standard keyboard, the 'single-quote/double-quote' key)
- OEM8 (Used for miscellaneous characters; it can vary by keyboard)
sendkeyalt
Use this function exactly as sendkey is used. It provides an alternative way of sending the key presses to the flight simulator if sendkey does not work.
sleep
USAGE: sleep( uint time )
PURPOSE: Suspends processing of the Lua script for the time specified in milliseconds. 1000 milliseconds = 1 Second.
EXAMPLE: sleep(75)
EXAMPLE EXPLAINED: This will suspend the Lua script for 75 milliseconds.
INFO:
- Use the function to allow time for GIT and the flight simulator to sync and for Events to be completed before reading associated variables indicating switch states.
- Depending upon your PC's performance, normally a value of 50 or 75 is sufficient.
getlastinput
USAGE: getlastinput()
PURPOSE: Gets the state of the last GoFlight switch, rotary, button or selector used.
EXAMPLE: buttonState = getlastinput()
EXAMPLE EXPLAINED: This will get the state of the last GoFlight switch, rotary, button or selector used and assign it to the local Lua variable buttonState.
INFO:
- A switch will have a value of 1 for ON and 0 for OFF
- A rotary will have a negative value for ANTI-CLOCKWISE and a positive value for CLOCKWISE. With rotaries that support acceleration the value will indicate how fast the rotary was turned, from -3 to +3.
- A selector will have multiple positive values indicating the position chosen starting from 1.
- Push buttons will usually return 1, because the OFF button input is rarely assigned an Event.
- Only controls that have been assigned Events will return a state.
- This function is useful for writing Lua scripts that can handle multiple states of a control. For example the Lua script could branch off, based on the current state, so it can handle Events for the ON state or the OFF state without having to write two separate Lua scripts.