Modules
- Gremlin
Module Gremlin
Gremlin.
DO NOT EDIT THIS SCRIPT DIRECTLY! Things WILL break that way.
Instead, pass a table to Gremlin:setup()
with any options you wish to configure.
Enums
Name | Summary |
---|---|
Periods | Time period "constants", in seconds. |
SideToText | Coalition name from ID. |
Comms
Name | Summary |
---|---|
Gremlin.comms.displayMessageTo(_name, _text, _time) | Display message to target. |
Gremlin.comms.playClipTo(_name, _path) | Play sound file for target. |
Events
Name | Summary |
---|---|
Gremlin.events.fire(_event) | Fire an event. |
Gremlin.events.idToName | Event name lookup. |
Gremlin.events.off(_eventId, _index) | Unregister an event handler. |
Gremlin.events.on(_eventId, _fn) | Register an event handler. |
Logging
Name | Summary |
---|---|
Gremlin.log.debug(toolId, message) | Log a message at the debug level. |
Gremlin.log.error(toolId, message) | Log a message at the error level. |
Gremlin.log.info(toolId, message) | Log a message at the info level. |
Gremlin.log.trace(toolId, message) | Log a message at the trace level. |
Gremlin.log.warn(toolId, message) | Log a message at the warn level. |
Menu
Name | Summary |
---|---|
Gremlin.menu.updateF10(toolId, commands, forUnits) | Update the F10 menu. |
Utils
Name | Summary |
---|---|
Gremlin.utils.countTableEntries(_tbl) | Count items in a table, numeric or otherwise. |
Gremlin.utils.getUnitZones(_unit) | Get a list of zones a unit is in. |
Gremlin.utils.inspect(_value, _depth) | Get a mostly-Lua representation of a value. |
Gremlin.utils.isInTable(_tbl, _needle) | Searches a table for a value. |
Gremlin.utils.mergeTables(...) | Combine two tables together. |
Gremlin.utils.parseFuncArgs(_args, _objs) | Parse arguments for things like menus. |
checkTrigger(_trigger, _type, _extra) | Check whether a trigger condition has been met. |
innerSquash(_tbl, _idx) | Flattens a table by removing the second level, rather than the first |
Top Level methods
Name | Summary |
---|---|
setup(config) | Setup Gremlin. |
Enums
Periods
Time period "constants", in seconds.
Fields:
- Second 1 second
- Minute 1 minute
- Hour 1 hour
- Day 1 day
SideToText
Coalition name from ID.
Fields:
- [0] Neutral
- [1] Red
- [2] Blue
Comms
Methods for handling communications with players.
Gremlin.comms.displayMessageTo(_name, _text, _time)
Display message to target. Finds a target by name, and then sends a text message.
Parameters:
- _name string, Unit or Group The name of the target to send a message to
- _text string The text to send
- _time number How long before the message should be dismissed
Gremlin.comms.playClipTo(_name, _path)
Play sound file for target. Finds a target by name, then plays a sound file.
Parameters:
- _name string, Unit or Group The name of the target to play sound to
- _path string The filename of the audio clip to play
Events
Methods for handling and firing events.
Gremlin.events.fire(_event)
Fire an event. NOTE: Only works between scripts that register handlers. It cannot send events back to DCS proper.
Parameters:
- _event table The event object to send to all relevant Gremlin handlers
Gremlin.events.idToName
Event name lookup. Not populated until setup is complete!
Gremlin.events.off(_eventId, _index)
Unregister an event handler.
Parameters:
- _eventId integer The DCS event ID to stop listening for
- _index integer The handler index to remove
Gremlin.events.on(_eventId, _fn)
Register an event handler.
Parameters:
- _eventId integer The DCS event ID to listen for
- _fn function The event handler to register
Returns:
- integer The handler index for later removal
Logging
Methods for logging things.
Gremlin.log.debug(toolId, message)
Log a message at the debug level.
Parameters:
Gremlin.log.error(toolId, message)
Log a message at the error level.
Parameters:
Gremlin.log.info(toolId, message)
Log a message at the info level.
Parameters:
Gremlin.log.trace(toolId, message)
Log a message at the trace level.
Parameters:
Gremlin.log.warn(toolId, message)
Log a message at the warn level.
Parameters:
Menu
Methods for setting up menus and keeping them up to date.
Gremlin.menu.updateF10(toolId, commands, forUnits)
Update the F10 menu.
Parameters:
- toolId string A string indicating the top level menu to create
- commands table A table of menu items to sync
- forUnits table A list of units who should be given menu access
Utils
Methods for miscellaneous script activities.
Gremlin.utils.countTableEntries(_tbl)
Count items in a table, numeric or otherwise.
Parameters:
- _tbl table The table to count entries within
Returns:
- integer The number of items in the table
Gremlin.utils.getUnitZones(_unit)
Get a list of zones a unit is in.
Parameters:
- _unit string The unit whose zones should be retrieved
Returns:
- table The list of unit zones
Gremlin.utils.inspect(_value, _depth)
Get a mostly-Lua representation of a value.
Parameters:
- _value any The value to inspect
- _depth integer How deep we've already inspected; should be 0 or nil
Returns:
- string A string representation of the value
Gremlin.utils.isInTable(_tbl, _needle)
Searches a table for a value.
Parameters:
- _tbl table The table to search
- _needle any The value to find
Returns:
- boolean Whether the needle was in the haystack
Gremlin.utils.mergeTables(...)
Combine two tables together. Doesn't care about integer versus string keys.
Parameters:
- ... table One or more tables to combine together
Returns:
- table The final combined result
Gremlin.utils.parseFuncArgs(_args, _objs)
Parse arguments for things like menus.
Parameters:
Returns:
- table The final (usable) arguments
checkTrigger(_trigger, _type, _extra)
Check whether a trigger condition has been met.
Parameters:
- _trigger table The trigger definition table to check against
- _type string The trigger type to check for
- _extra any Any extra data needed to perform the check, or nil
Returns:
- boolean Whether the trigger condition has been met
innerSquash(_tbl, _idx)
Flattens a table by removing the second level, rather than the first
Parameters:
Returns:
- table The flattened table
Top Level methods
setup(config)
Setup Gremlin.
Parameters:
- config table The settings table to configure Gremlin using
Last updated 2024-04-28 12:12:18