events
Named events between scripts. A node listens for a name and hears it as its on_<name> method; node.emit and events.emit send one.
On this page
Named events between scripts. A node listens for a name and hears it as its on_<name> 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). 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. |