Skip to content

Search

Documentation

events module

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.

ในหน้านี้

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.

6 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.
emitted(string) -> any — The payloads delivered under this name this frame whoever emitted them, in emission order; empty when none were.
emitted_from(node, string) -> any — The payloads delivered under this name this frame from that node, in emission order; empty when none were.
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.