Module copilot
(no description)
Functions
loadIniFile(path, cfg[, init]) | Loads (also creates, if it doesn't exist) an ini file into a lua table |
addCallback(callback[, name][, interval][, delay]) | Adds a callback to the callback queue. |
addCoroutine(callback[, name][, delay]) | Adds a coroutine callback |
callOnce(callback[, delay]) | Adds a callback to the callback queue that will be removed after running once. |
removeCallback(key) | Removes a previously added callback. |
keypress(keys) | Simulates a key press |
displayText(text[, duration=0][, type="print_white"]) | Display a SimConnect text message |
sleep([time1[, time2]]) | If both parameters omitted: ipc.sleep (100)If time1 specified: ipc.sleep(time1) If both are specified: ipc.sleep(math.random(time1, time2)) |
suspend([time1[, time2]]) | If both parameters omitted: coroutine.yield() Otherwise, suspend the execution of this coroutine for: If time1 specified: time1 milliseconds If time1 and time2 specified: random amount of milliseconds between time1 and time2 |
onGround() | Returns true if you're on the ground. |
GS() | Returns the ground speed in knots. |
radALT() | Returns the radio altitude in meters. |
IAS() | Returns the IAS in knots. |
reverseThrustSelected() | Returns true if the thrust levers are below the IDLE position. |
ALT() | Returns the altitude in feet referenced to 1013 hPa. |
CG() | Returns the sim CG variable |
thrustLeversSetForTakeoff() | Returns true if the thrust levers in the CLB detent or above. |
enginesRunning(both) | Returns true if the engines are running. |
getFltSimCfg() | Reads the fltsim.cfg (the FSLabs airframe config file) and returns it as a string |
appendSequence(name, func) | Appends a function to a default sequence |
prependSequence(name, func) | Prepends a function to a default sequence |
replaceSequence(name, func) | Replaces a default sequence |
Tables
events | Predefined events |
voiceCommands | Predefined voice commands |
actions | Predefined actions |
sequences | Predefined sequences |
checklists | Predefined checklists |
Functions
Methods- loadIniFile(path, cfg[, init])
-
Loads (also creates, if it doesn't exist) an ini file into a lua table
Parameters:
- path string
- cfg table The format of the ini file (see usage below)
- init table If specified, loadIniFile will not create a new table, but will populate this table instead. (optional)
Returns:
-
table
The table with the options (see usage below). If init was specified, it will be the same table.
Usage:
local optionsCfg = { { title = "Section1", keys = { { name = "enable", default = copilot.UserOptions.TRUE, comment = "a comment", type = "bool" -- other types: "int", "double" or "number", "enum", "string" } } }, { title = "SeCtiOn2", keys = { { name = "fruit", type = "enum", default = "apple", required = true, values = {"apple", "orange", "banana"} } } } } local options = copilot.loadIniFile(APPDIR .. "my_ini_file.ini", optionsCfg) print( ("section1.enable: %s, section2.fruit: %s") :format(options.section1.enable, options.section2.fruit) )
- addCallback(callback[, name][, interval][, delay])
-
Adds a callback to the callback queue.
Parameters:
- callback
A function, callable table or thread. It will be called the following arguments:
A timestamp (same as copilot.getTimestamp())
itself
- name string Can be used later to remove the callback with removeCallback. (optional)
- interval int Interval in milliseconds (optional)
- delay int Initial delay in milliseconds (optional)
Returns:
- The callback that was passed in.
-
An Event that will be signaled when the coroutine :
Finishes its execution normally.In this case, the event's payload will be the values returned by the coroutine.
Is removed with removeCallback. The payload will be copilot.THREAD_REMOVED
- callback
- addCoroutine(callback[, name][, delay])
-
Adds a coroutine callback
Parameters:
- callback A function or thread. If it's a function, addCoroutine will call coroutine.create itself.
- name string Same as addCallback (optional)
- delay int Same as addCallback (optional)
Returns:
-
The same values as addCallback
- callOnce(callback[, delay])
-
Adds a callback to the callback queue that will be removed after running once.
It doesn't matter whether you use addCallback or callOnce with coroutines as a coroutine instance cannot run twice.
Parameters:
- callback Same as addCallback
- delay int Same as addCallback (optional)
Returns:
-
The same values as addCallback
- removeCallback(key)
-
Removes a previously added callback.
Parameters:
- key Either the callable itself or the name passed to addCallback
- keypress(keys)
-
Simulates a key press
Parameters:
Usage:
copilot.keypress "CONTROL+SHIFT+F12"
- displayText(text[, duration=0][, type="print_white"])
-
Display a SimConnect text message
Parameters:
- text string Text to be displayed. May include line breaks.
- duration int Duration in seconds. 0 means infinite. (default 0)
- type string "type_black", "type_white", "type_red", "type_green", "type_blue", "type_yellow", "type_magenta", "type_cyan" where type is either print or scroll (default "print_white")
Usage:
copilot.displayText("hello", 10, "print_cyan")
- sleep([time1[, time2]])
-
If both parameters omitted:
ipc.sleep
(100)
If time1 specified:ipc.sleep(time1)
If both are specified:ipc.sleep(math.random(time1, time2))
Parameters:
- time1 int (optional)
- time2 int (optional)
- suspend([time1[, time2]])
-
If both parameters omitted:
coroutine.yield()
Otherwise, suspend the execution of this coroutine for:
If time1 specified: time1 milliseconds
If time1 and time2 specified: random amount of milliseconds between time1 and time2Parameters:
- time1 int (optional)
- time2 int (optional)
- onGround()
- Returns true if you're on the ground.
- GS()
- Returns the ground speed in knots.
- radALT()
- Returns the radio altitude in meters.
- IAS()
- Returns the IAS in knots.
- reverseThrustSelected()
- Returns true if the thrust levers are below the IDLE position.
- ALT()
- Returns the altitude in feet referenced to 1013 hPa.
- CG()
- Returns the sim CG variable
- thrustLeversSetForTakeoff()
- Returns true if the thrust levers in the CLB detent or above.
- enginesRunning(both)
-
Returns true if the engines are running.
Parameters:
- both bool If true, will return true if both engines are running. If omitted or false, returns true if either engine is running.
- getFltSimCfg()
-
Reads the fltsim.cfg (the FSLabs airframe config file) and returns it as a string
Returns:
-
string
The content of the file. An empty string is returned if the file couldn't be read.
- appendSequence(name, func)
-
Appends a function to a default sequence
Parameters:
- name string Name of the sequence in in options.ini or in the code
- func function The function to append
Usage:
copilot.appendSequence("lineup", function() FSL.OVHD_EXTLT_Nose_Switch "TO" FSL.OVHD_EXTLT_Strobe_Switch "AUTO" end)
- prependSequence(name, func)
-
Prepends a function to a default sequence
Parameters:
- name string Name of the sequence in in options.ini or in the code
- func function The function to prepend
- replaceSequence(name, func)
-
Replaces a default sequence
Parameters:
- name string Name of the sequence in in options.ini or in the code
- func function New sequence