Skip to content

Search

Documentation

events

Named events between scripts. A node hears its own events, and after listen another node's, as its on_<name>(payload, source) method; node.emit and…

On this page

Named events between scripts. A node hears its own events, and after listen another node's, as its on_<name>(payload, source) method; node.emit and events.emit send one.

4 functions, 0 constants. Scripts reach it as events::.

Functions

Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.

function acts on what it does
emit(string, any) — Queue an event from no particular node, delivered at the top of the next frame's update to whoever listens for the name from anyone.
listen(Node, string, Node?) — Hear an event on this node, as its script's on_<name>(payload, source), source being the node that said it, or nil for one said from no node. Pass the node whose events to hear, or leave it out for every emitter. Listening twice is once.
next(string, Node?) -> int — A token for task.wait that wakes, with the payload, the next time the name is delivered from that node or, left out, from anyone: let payload = task::wait(events::next("finished", door)).await;, a GDScript await door.finished.
stop_listening(Node, string, Node?) — Stop hearing an event on this node, from being the emitter it listened with. Not an error when it never listened.

Are you sure?