eg-overlay#

local overlay = require 'eg-overlay'

The eg-overlay module contains core functions that other modules use to communicate with the overlay.

Functions#

eg-overlay.addeventhandler(event, handler)#

Add an event handler for the given event name.

The handler function will be called every time that particular event is posted with two arguments: the event name and event data. The may be nil, any Lua data type or a jansson.json object.

Parameters:
  • event (string) – Event type

  • handler (function) – Function to be called on the given event

Returns:

A callback ID that can be used with removeeventhandler().

Return type:

integer

Version History

Version

Notes

0.0.1

Added

0.1.0

Renamed from add_event_handler to addeventhandler

eg-overlay.removeeventhandler(event, cbi)#

Remove an event handler for the given event name. The callback ID is returned by addeventhandler().

Parameters:
Returns:

none

Version History

Version

Notes

0.0.1

Added

0.1.0

Renamed from remove_event_handler to removeeventhandler

eg-overlay.queueevent(event, data)#

Add a new event to the queue.

Parameters:
  • event (string) – Event type

  • data – Optional event data

Returns:

none

Note

Events are dispatched in the order they are queued each render frame. Events that are queued during an event callback will be dispatched on the following frame.

Version History

Version

Notes

0.0.1

Added

0.1.0

Renamed from queue_event to queueevent

eg-overlay.time()#

Returns the fractional number of seconds since the overlay was started. This can be used to time animations, events, etc.

Returns:

Time value

Return type:

number

Version History

Version

Notes

0.0.1

Added

eg-overlay.settings()#

Returns a settings object for the overlay itself, which holds core settings and defaults.

Return type:

settings

Version History

Version

Notes

0.0.1

Added

eg-overlay.memusage()#

Returns a table containing the memory usage of the overlay. These statistics are for the application as a whole, and not just Lua.

Returns:

Memory usage

Return type:

table

Field

Description

working_set

The current memory in use by the overlay, in bytes.

peak_working_set

The maximum amount of memory the overlay has used

Version History

Version

Notes

0.0.1

Added

0.1.0

Renamed from mem_usage to memusage

eg-overlay.videomemusage()#

Returns the video memory usage of the overlay, in bytes.

Returns:

Video memory usage

Return type:

number

Version History

Version

Notes

0.1.0

Added

eg-overlay.processtime()#

Returns a table containing the CPU time and uptime of the overlay. This can be used to calculate the overlay’s CPU usage.

Returns:

Process time

Return type:

table

Field

Description

process_time_total

The total time the overlay has been running.

user_time

The total time spent executing code within the overlay.

kernel_time

The total time spent executing system code for the overlay, not including idle time.

system_user_time

The total time spent executing all application code on the system.

system_kernel_time

The total time spent executing system code on the system, including idle time.

Version History

Version

Notes

0.0.1

Added

0.1.0

Renamed from process_time to processtime

eg-overlay.datafolder(name)#

Returns the full path to the data folder for the given module.

Modules should store any data other than settings in this folder. The folder will be created by this function if it does not already exist.

Parameters:

name (string) – The name of the module and corresponding folder.

Returns:

The full path to the module data folder.

Return type:

string

Version History

Version

Notes

0.0.1

Added

0.1.0

Renamed from data_folder to datafolder

eg-overlay.clipboardtext([text])#

Set or return the text on the clipboard.

Parameters:

text (string) – (Optional) If present, the text to set the clipboard to.

Returns:

If text is nil, returns the text currently on the clipboard. Otherwise nil.

Return type:

string

Version History

Version

Notes

0.0.1

Added

0.1.0

Renamed from clipboard_text to clipboardtext

eg-overlay.exit()#

Exit EG-Overlay.

Danger

This will unconditionally and immediately cause the overlay to shutdown. Most modules will not use this function.

Version History

Version

Notes

0.0.1

Added

eg-overlay.findfiles(path)#

Return a sequence containing the files and directories matching path.

path can contain wildcards.

Each file returned will be a table with the following fields:

Field

Description

name

File/directory name.

type

'directory' or 'file'.

hidden

true or false.

system

true or false.

readonly

true or false.

Parameters:

path (string)

Return type:

sequence

Version History

Version

Notes

0.1.0

Added

eg-overlay.uuid()#

Return a new Universally Unique Identifier (UUID).

The returned UUID is a string in ‘8-4-4-12’ format.

Return type:

string

Version History

Version

Notes

0.1.0

Added

eg-overlay.uuidtobase64(uuid)#

Convert a UUID from an ‘8-4-4-12’ format string to a BASE64 encoded string.

Parameters:

uuid (string)

Return type:

string

Version History

Version

Notes

0.1.0

Added

eg-overlay.uuidfrombase64(base64uuid)#

Convert a UUID from a BASE64 encoded string to an ‘8-4-4-12’ format string.

Parameters:

base64uuid (string)

Return type:

string

Version History

Version

Notes

0.1.0

Added

eg-overlay.currentdirectory()#

Return the current working directory as a string.

Return type:

string

Version History

Version

Notes

0.1.0

Added

eg-overlay.logicaldrives()#

Return a table containing a list of the valid drive letters, i.e. ‘C’, ‘D’, etc.

Return type:

table

Version History

Version

Notes

0.1.0

Added

Events#

startup#

The startup event is sent once before the start of the render thread. Modules can use this event to initialize or load data.

Version History

Version

Notes

0.0.1

Added

update#

Sent once per frame before any drawing has occurred.

Version History

Version

Notes

0.0.1

Added

draw-3d#

Sent once per frame, after update but before the UI has been drawn. Modules should use this event to draw 3D information below the UI.

Version History

Version

Notes

0.0.1

Added