new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Godot 4 Patterns · all subjects

signals

6 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Signal declaration with typed arguments

Signals should be declared with typed arguments. Example: signal player_died(reason: String) and signal item_collected(item_id: String, count: int).

Connect signals with explicit Callable

Connect signals using the explicit Callable pattern: signal_owner.player_died.connect(_on_player_died).

Emit signals with .emit()

Emit signals using the .emit() method with arguments: signal_owner.player_died.emit("starvation").

Game-wide signal hub pattern

For game-wide events, use an autoload signal hub to decouple publisher and subscriber. Create game_signals.gd as an autoload extending Node with signal declarations, then connect and emit from anywhere using GameSignals.signal_name.

Signal hub pattern with game_signals autoload

Create a single game_signals autoload to decouple publishers from subscribers entirely. Define all game-wide events in one place: terminal_command_submitted, overlay_requested, overlay_closed, time_advanced, stat_changed, room_changed, achievement_unlocked, sfx_requested, ambient_changed. Anything can publish with GameSignals.signal_name.emit() and subscribe with GameSignals.signal_name.connect(_on_handler).

Diagnose signal connection and emission failures

To verify signal connection succeeded, capture the error: var err := signal.connect(_handler); print("connect err=%d" % err). Test emit separately: signal.emit("test"); print("emitted"). In the handler, log receipt: func _handler(arg) -> void: print("[Handler] received: %s" % arg). If the handler does not print, either the signal did not fire or the connect failed silently (e.g., callable was invalid because the node was freed).

Give your agent this brain