game.gd connects autoload signals in the editor, erroring on scene load #149

Closed
opened 2026-10-10 15:29:58 +01:00 by liamjd · 0 comments
Owner

game.gd is a @tool script, so its _ready() also runs when the editor opens game.tscn. Three signal connections sit outside the if not Engine.is_editor_hint(): guard:

GameState.building_placed.connect(_add_building_to_map)
GameState.building_removed.connect(_remove_building_from_map)
GameClock.tick.connect(pawns.on_tick)

In the editor, the autoloads aren't @tool scripts, so GameState and GameClock are plain Nodes without their own code or signals. The first line errors, and _ready() stops there:

SCRIPT ERROR: Invalid access to property or key 'building_placed' on a base object of type 'Node (GameState.gd)'.
   at: _ready (res://common/game.gd:72)

This shows up in the editor's Output panel and in --headless --editor --quit. It is editor-only: when the game runs, the autoloads are real and the connections succeed.

Fix

Move the three lines inside the existing if not Engine.is_editor_hint(): block. They are game wiring, and nothing in the editor needs them.

Acceptance criteria

  • --headless --editor --quit prints no script errors.
  • Placing and removing buildings still updates navigation, and pawns still tick, in the running game.
  • GUT suite green.
`game.gd` is a `@tool` script, so its `_ready()` also runs when the editor opens `game.tscn`. Three signal connections sit outside the `if not Engine.is_editor_hint():` guard: ```gdscript GameState.building_placed.connect(_add_building_to_map) GameState.building_removed.connect(_remove_building_from_map) GameClock.tick.connect(pawns.on_tick) ``` In the editor, the autoloads aren't `@tool` scripts, so `GameState` and `GameClock` are plain `Node`s without their own code or signals. The first line errors, and `_ready()` stops there: ``` SCRIPT ERROR: Invalid access to property or key 'building_placed' on a base object of type 'Node (GameState.gd)'. at: _ready (res://common/game.gd:72) ``` This shows up in the editor's Output panel and in `--headless --editor --quit`. It is **editor-only**: when the game runs, the autoloads are real and the connections succeed. ## Fix Move the three lines inside the existing `if not Engine.is_editor_hint():` block. They are game wiring, and nothing in the editor needs them. ## Acceptance criteria - [ ] `--headless --editor --quit` prints no script errors. - [ ] Placing and removing buildings still updates navigation, and pawns still tick, in the running game. - [ ] GUT suite green.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
liamjd/UntitledColonyBuilder#149
No description provided.