Event API

Lua Lib: event

The Event API provides classes, functions and variables for interacting with the component network.

Functions

listen(Component)

Adds the running lua context to the listen queue of the given component.

Parameters
Name Type Description

Component

Component

The network component lua representation the computer should now listen to.

Object[] listening()

Returns all signal senders this computer is listening to.

Return Values
Name Type Description

Object[]

Object[]

An array containing instances to all sginal senders this computer is listening too.

ignore(Component…​)

Removes the running lua context from the listen queue of the given components. Basically the opposite of listen.

Parameters
Name Type Description

Component…​

Component…​

The network component lua representations the computer should stop listening to.

ignoreAll()

Stops listening to any signal sender. If afterwards there are still coming signals in, it might be the system itself or caching bug.

clear()

Clears every signal from the signal queue.

string e, Component s, …​ pull([number timeout])

Waits for a signal in the queue. Blocks the execution until a signal got pushed to the signal queue, or the timeout is reached.

Returns directly if there is already a signal in the queue (the tick doesn’t get yielded).

Parameters
Name Type Description

timeout

number

The amount of time needs to pass until pull unblocks when no signal got pushed. If not set, the function will block indefinitely until a signal gets pushed. If set to 0 (int), will not yield the tick and directly return with the signal data or nil if no signal was in the queue.

Return Values
Name Type Description

e

string

The name of the returned signal.

Nil when timeout got reached.

s

Component

The component representation of the signal sender.

Not set when timeout got reached.

…​

…​

The parameters passed to the signal.

Not set when timeout got reached.

Apis