← ExekiteCONTENT HISTORY
WHAT CHANGED
Update to Exekite
Snapshot Nov 17, 2026 · 12:11 UTC · version 1.0.0
Collection source: downloaded plugin package.
First saved snapshot
No earlier snapshot is available to establish a change.
Save Exekite and check future changes in Following.
Up to 3 plugins free · no card required.
Compare saved observations
Download comparison JSONFull technical diff · 0 changed fields
Full snapshot data
{
"description": "For Exekite-hosted Godot games only. Godot 4 signal mechanics — callable-form connect, bind, one-shot, deferred — and the signal-up/call-down rule. Use when a connection misfires or targets a node spawned later, when several unrelated systems need one event without a global bus, or when state must survive a scene change.",
"included_files": [],
"name": "signals-and-events",
"skill_md_contents": "---\nname: signals-and-events\ndescription: \"For Exekite-hosted Godot games only. Godot 4 signal mechanics — callable-form connect, bind, one-shot, deferred — and the signal-up/call-down rule. Use when a connection misfires or targets a node spawned later, when several unrelated systems need one event without a global bus, or when state must survive a scene change.\"\n---\n\n# Signals and events\n\nSignals are how Godot decouples the thing that did something from the thing that reacts. Used well, they keep code testable and free of references that don't need to exist.\n\n## Declaring and emitting\n\n```gdscript\n# In any node script:\nsignal coin_collected(amount: int)\nsignal player_died\n\nfunc collect(value: int) -> void:\n coin_collected.emit(value) # 4.x: signal_name.emit(args)\n\nfunc _on_hit_zero_hp() -> void:\n player_died.emit() # no-arg signal — same syntax\n```\n\nTyped signal arguments are recommended; they document intent and surface bad emits.\n\n## Connecting (callable form)\n\nThe Godot 4 connect API takes a `Callable`, not a string:\n\n```gdscript\n# RIGHT (4.x)\nbutton.pressed.connect(_on_button_pressed)\ncoin.coin_collected.connect(_on_coin_collected)\n\n# WRONG (3.x style, doesn't compile in 4)\n# button.connect(\"pressed\", self, \"_on_button_pressed\")\n```\n\nDisconnecting:\n```gdscript\nbutton.pressed.disconnect(_on_button_pressed)\n```\n\nBind extra arguments at connect time:\n```gdscript\n# Pass `slot` as a final arg every time the signal fires:\ninventory_slot.clicked.connect(_on_slot_clicked.bind(slot))\n```\n\nOne-shot connection (auto-disconnects after firing once):\n```gdscript\ntween.finished.connect(_after_tween, CONNECT_ONE_SHOT)\n```\n\nDeferred (runs at idle, not synchronously inside the emit):\n```gdscript\nsig.connect(_handler, CONNECT_DEFERRED)\n```\n\n## Connections declared in the scene file\n\nA `.tscn` can declare connections as text — this is what editor-made connections serialize to:\n\n```\n[connection signal=\"pressed\" from=\"UI/StartButton\" to=\".\" method=\"_on_start_pressed\"]\n```\n\n`from`/`to` are node paths relative to the scene root (`.` is the root); the target method must exist in the target's script or the scene fails to load. Use `[connection]` stanzas for static, scene-internal wiring; use script `connect()` for anything that depends on runtime state (spawned children, cross-scene wiring).\n\n## Signal-up, call-down — the discipline\n\n**Signal-up**: a child node never reaches into its parent and calls a method. The child emits; the parent listens.\n\n```gdscript\n# Coin (child of level)\nsignal collected(amount: int)\nfunc _on_body_entered(body: Node) -> void:\n if body.is_in_group(\"player\"):\n collected.emit(1)\n\n# Level (parent)\nfunc _ready() -> void:\n for c in $Coins.get_children():\n c.collected.connect(_on_coin_collected)\n\nfunc _on_coin_collected(amount: int) -> void:\n score += amount # the root game script owns cross-scene state (no GameState autoload in freeform games)\n```\n\n**Call-down**: a parent reaching into a known child via a typed reference is fine.\n\n```gdscript\n@onready var hud: HUD = $HUD\nfunc _on_player_died() -> void:\n hud.show_game_over()\n```\n\nThe asymmetry: the child doesn't need to know who owns it; the parent does know what's beneath it.\n\n## When direct calls are fine\n\nSignals aren't always right. Direct calls beat signals when:\n\n- The dependency is one-way and obvious (call the root game script's `die()` from the player (passed-down reference)). In freeform games the ROOT GAME SCRIPT owns shared state (there is no GameState autoload); don't fan out via a signal just to pretend it doesn't.\n- There's exactly one consumer and there always will be (HUD listening to player health — sure, signal works, but a direct call is also fine).\n\n## Fan-out across unrelated systems (no autoload exists)\n\nThere is **no `EventBus`, no `GameState`, no shell** in an authored game. The\nharness writes `project.godot` with the entire `[autoload]` section stripped, and\nyou may not write `addons/`, so every global singleton name you might have seen\nelsewhere is an undeclared identifier here — a parse error the gate catches.\n\nWhen several unrelated systems need the same event, put the bus on your ROOT\ngame script and let listeners find it by group. One node, no globals:\n\n```gdscript\n# Main.gd — the root of scenes/Main.tscn\nextends Node2D\n\nsignal game_event(name: StringName, payload: Variant)\n\nfunc _enter_tree() -> void:\n add_to_group(\"game_root\")\n\nfunc post(name: StringName, payload: Variant = null) -> void:\n game_event.emit(name, payload)\n```\n\n```gdscript\n# Any node, however deep, without a reference passed down to it\nfunc _ready() -> void:\n var root := get_tree().get_first_node_in_group(\"game_root\")\n if root != null:\n root.game_event.connect(_on_game_event)\n\nfunc _on_game_event(name: StringName, payload: Variant) -> void:\n match name:\n &\"player_died\": ...\n &\"coin_picked\": var amount: int = payload.get(\"amount\", 1)\n```\n\nRegister the root group in `_enter_tree`, before its children's `_ready`\nhandlers look it up. Registering in the root's `_ready` is too late: children\nrun `_ready` first and silently miss the connection.\n\n`get_first_node_in_group` returns `null` when nothing is in the group, so the\nguard above is not optional — a scene opened on its own for testing has no root.\n\n**Prefer a passed-down reference when you have one.** The group lookup is for\nnodes that are spawned deep and cannot be handed anything. A direct typed\nreference is faster to read and impossible to get wrong.\n\n## Disconnecting on tree exit\n\nA method-callable connection is severed automatically when either endpoint is\nfreed — a listener that dies with its scene needs no manual disconnect.\nDisconnect explicitly only when (a) the listener leaves the tree but stays\nALIVE (reparented or pooled — it keeps receiving events), or (b) the connection\nis a lambda, which has no bound object and is never auto-cleaned:\n\n```gdscript\nfunc _exit_tree() -> void:\n var root := get_tree().get_first_node_in_group(\"game_root\")\n if root != null and root.game_event.is_connected(_on_game_event):\n root.game_event.disconnect(_on_game_event)\n```\n\nConnections from a node to its own children, or to nodes that share its\nlifetime, don't need this — they are all freed together.\n\n## Signals across a scene change\n\nA signal emitted on a node that is about to be freed is gone the moment the\nscene unloads. With no autoload to outlive the scene, carry the state instead of\nthe event: keep it on the root game script and change scenes through it, or pass\nit into the next scene after `change_scene_to_file` via a value the new scene\nreads on `_ready`.\n\n## Initialize state after connecting\n\nSignals carry changes; they do not replay the current value for a new listener.\nChildren run `_ready()` before their parent, so a health signal emitted there is\nalready over when the parent's `_ready()` connects it. Render the initial state\nexplicitly after wiring the listener:\n\n```gdscript\n# In the parent that owns Player and HUD:\nfunc _ready() -> void:\n $Player.health_changed.connect($HUD.update_health)\n $HUD.update_health($Player.health, $Player.max_health)\n```\n\nUse the same pattern for score, cooldown and inventory. Verify the HUD before the\nfirst pickup or hit; a correct update handler can coexist with an empty initial HUD.\nFor state that survives scene reloads, read its owner again when rebuilding the UI.\nFor example, initialize a mute toggle from\n`AudioServer.is_bus_mute(AudioServer.get_bus_index(\"Master\"))`; a new scene's\n`false` default does not unmute the global audio bus.\n\n## Anti-patterns\n\n- The Godot 3 string-based `connect(\"signal\", target, \"method\")` form. Doesn't compile in 4. Always use the callable form.\n- Reaching for a global singleton — `EventBus`, `GameState`, `AudioManager` and the rest are STRIPPED from `project.godot`. Any of them used as a global is an undeclared identifier at parse time.\n- Forgetting `.connect()` after declaring a signal. The signal is a no-op until something connects.\n- Connecting in `_ready()` to a child that doesn't exist yet (e.g. spawned dynamically later in `_ready`). Move the connect to right after the `add_child` call.\n- Untyped args on your OWN local signals. `signal hit(damage)` is legal but `signal hit(damage: int)` documents intent and catches bad emits.\n- Expecting a signal to survive a scene change. The emitter is freed with its scene; carry the STATE on the root game script instead of trying to carry the event.\n"
}SHA-256 of public snapshot: aa7feab3ec3f75ee27685493c08fd16c3e6f9e505d55bbeb357881a482914d70