Class Checklist
Functions
Checklist.currChecklist() | Returns the checklist that is currently being executed |
Methods
Checklist:new(label, displayLabel, trigger) | Constructor |
Checklist:currItem() | Returns the current item that is being executedm or nil. |
Checklist:appendItem(item) | Add new item to the end of the checklist. |
Checklist:getItem(label) | Gets item by its label |
Checklist:replaceItem(item) | Replaces the item with the same label as item.label. |
Checklist:insertItem(label, item) | Inserts an item after the item with the given label |
Checklist:removeItem(label) | Removes the item with the given label |
Functions
Methods- Checklist.currChecklist()
-
Returns the checklist that is currently being executed
Returns:
- The checklist itself or nil.
- The current item, if there is a checklist, or nil.
Methods
- Checklist:new(label, displayLabel, trigger)
-
Constructor
Parameters:
- label string The name of the folder in copilot\sounds\callouts where the checklist-related callouts are located.
- displayLabel string Name of the checklist that will be displayed in the message windows and logs
- trigger
A VoiceCommand that's going to be the trigger for your checklist. It can be accessed through the trigger field.
Use it to control the availability of the checklist by calling
myChecklist.trigger:activate()/deactivate()
(see copilot\initChecklists.lua)
- Checklist:currItem()
- Returns the current item that is being executedm or nil.
- Checklist:appendItem(item)
-
Add new item to the end of the checklist. Browse the lua files at copilot\checklists for examples.
Parameters:
- item A table with the following fields (only
label
andresponse
are required):- label string The name of the sound file inside copilot\sounds\callouts\checklistLabel
- response
Either a VoiceCommand or a table in the
label=VoiceCommand
key=value format where label is a string that will be passed to item.onResponse. Ifresponse
is a single voice command, it is converted to a table with one key: "response". - displayLabel string The name of the item that will be displayed in message windows and logs (optional)
- acknowledge string The name of the sound file inside copilot\sounds\callouts\checklistLabel that will be played if the response to the challenge is correct. If absent, no callout is played. (optional)
- onResponse
function
A function that will be called following the response to decide whether the response was correct. It receives the following parameters:
A check function.
If it's called with a string as the single argument, the check is considered failed and the string describes the reason.
If it's called with two arguments, the first argument is evaluated for truthiness: if the value is falsy, the check is considered failed and the second string argument describes the reason.
The reason string is used for logging and is displayed in a message window if display_fail=1.
The function returns a bool that indicates whether the check succeeded
A RecoResult object
The response voice command label
A table where you can set some flags to control what happens next. The only field available is "acknowledge", which overrides item.acknowledge (see the flapSetting item in coplot\checklists\beforeTakeoff.lua for an example). This table also provides the function
didFail
which returns true if the check function failed at least once.The item. The response voice command can be accessed through item[label]
- beforeChallenge function A function to be called before the challenge. It receives the item itself as the only parameter. (optional)
- item A table with the following fields (only
- Checklist:getItem(label)
-
Gets item by its label
Parameters:
- label string
Returns:
-
The item
- Checklist:replaceItem(item)
-
Replaces the item with the same label as item.label.
Parameters:
- item Same as in Checklist:appendItem
Returns:
-
self
- Checklist:insertItem(label, item)
-
Inserts an item after the item with the given label
Parameters:
- label string Label of the item after which the new item is to be inserted
- item Same as in Checklist:appendItem
Returns:
-
self
- Checklist:removeItem(label)
-
Removes the item with the given label
Parameters:
- label string
Returns:
-
self