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

debugging/focus

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

Debug focus owner each frame

To debug focus problems, print the current focus owner every frame: func _process(_dt): print("focus: ", get_viewport().gui_get_focus_owner()). This reveals when focus unexpectedly changes or becomes null.

Focus debugging checklist

When debugging focus issues: 1. Print focus owner every frame with get_viewport().gui_get_focus_owner(). 2. Check Inspector on LineEdit: Focus tab should show focus_mode = ALL. 3. Check siblings: do they have focus_mode = ALL and mouse_filter != IGNORE? 4. Check overlays: are they hidden (visible=false) or just invisible (modulate.a=0)? Hidden and invisible are not equivalent. 5. Check toast/notification: if visible=true, ensure mouse_filter = IGNORE and focus_mode = NONE.

Diagnose scene load failure with error codes

When change_scene_to_file() does not transition, capture and print the error code: var err := get_tree().change_scene_to_file(path); print("change_scene err=%d for %s" % [err, path]). Common error codes: 0 (OK) means success. 7 (ERR_CANT_OPEN) means file missing or wrong path. 19 (ERR_PARSE_ERROR) means script in scene has syntax error. 1 (FAILED) is generic; check for autoload crash.

@onready null check and timing issue

In Godot 4, @onready variables resolve AFTER _ready() of children completes. If you access @onready var X from a child's signal that fires during _ready(), X may be null. Always check: @onready var btn: Button = $Path/To/Button; func _ready() -> void: if btn == null: push_error("btn is null! check scene path").

Live remote tree inspection while game runs

While the game is running, use the Remote tab to inspect live state: (1) Click Editor → bottom panel → Remote tab. (2) Click the running scene root. (3) Browse the live node tree. (4) Click any node to show current values in the Inspector. (5) Modify values live (changes do not persist). This is invaluable for checking 'is the LineEdit actually focused?' type questions.

Give your agent this brain