The following detail extensions made to the Lua implementation for the specific purpose of interacting with GIT and X-Plane. 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.
sendcmd
USAGE: sendcmd( string cmdName )
PURPOSE: Sends a Command to X-Plane.
EXAMPLE: sendcmd("sim/engines/fire_ext_1_on")
EXAMPLE EXPLAINED: This will send the Command "sim/engines/fire_ext_1_on" to X-Plane. The Command turns on the first fire extinguisher.
INFO: n/a
getdref
USAGE: getdref( string datarefName )
PURPOSE: Gets the value of a Dataref.
EXAMPLE: fireExt1On = getdref("sim/cockpit2/engine/actuators/fire_extinguisher_on[1]")
EXAMPLE EXPLAINED: The local Lua variable fireExt1On will be set to a value of 1 if the first fire extinguisher is on, otherwise it will be set 0.
INFO: n/a
setdref
USAGE: setdref( string datarefName, double Value )
PURPOSE: Sets the value of a Dataref.
EXAMPLE: setdref("sim/cockpit/autopilot/heading_mag", 157)
EXAMPLE EXPLAINED: This sets the autopilots heading to 157 degrees magnetic.
INFO: n/a
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".
sendkey
USAGE: sendkey( string character, <enum keyFlag> )
PURPOSE: Sends a key press or combination of key presses to X-Plane.
EXAMPLE: sendkey ( "e", CONTROL | SHIFT )
EXAMPLE EXPLAINED: This will send the key combination of Control, Shift and "e" to X-Plane which will start the engines in default aircraft.
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 X-Plane 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 X-Plane 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.