Powerup: Don't access GameState in editor or before _ready#2359
Merged
manuq merged 1 commit intoJun 12, 2026
Merged
Conversation
Previously, during export:
SCRIPT ERROR: Invalid access to property or key 'quest' on a base object of type 'Node (game_state.gd)'.
at: _update_ability_name (res://scenes/game_elements/props/powerup/components/powerup.gd:65)
GDScript backtrace (most recent call first):
[0] _update_ability_name (res://scenes/game_elements/props/powerup/components/powerup.gd:65)
[1] _set_ability (res://scenes/game_elements/props/powerup/components/powerup.gd:43)
SCRIPT ERROR: Invalid assignment of property or key 'action' with value of type 'String' on a base object of type 'Nil'.
at: _set_ability (res://scenes/game_elements/props/powerup/components/powerup.gd:44)
GDScript backtrace (most recent call first):
[0] _set_ability (res://scenes/game_elements/props/powerup/components/powerup.gd:44)
`powerup.gd` is a `@tool` script (so that its appearance
can be updated based on the sprite_frames property, I guess) but
`game_state.gd` is not. But the `Powerup.ability` setter would
previously try to use properties of GameState unconditionally.
In `_set_ability`, skip `_update_ability_name()` in two cases:
1. When running in the editor: GameState is not available here, and the
`ability_name` property and the interact area's action description
aren't used in the editor anyway.
2. When not _ready(): When playing a specific scene with `F6`, GameState
will not be _ready() at the point where the scene containing the
powerup is added to the tree. So `GameState.quest` will be null and
the powerup will always be named after the default abilities:
incorrect if the quest eventually turns out to have custom names.
`_set_ability` is called again from `_ready` (in our standard pattern)
so this should cause no behaviour change in-game.
Helps #2353
|
Play this branch at https://play.threadbare.game/branches/endlessm/wjt/powerup-don-t-access-gamestate-in-editor-or-before-ready/. (This launches the game from the start, not directly at the change(s) in this pull request.) |
manuq
approved these changes
Jun 12, 2026
Comment on lines
+43
to
+44
| if not Engine.is_editor_hint() and is_node_ready(): | ||
| _update_ability_name() |
Collaborator
There was a problem hiding this comment.
Excellent, thanks for the detailed description of the problem.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, during export:
And when editing a scene that uses a powerup in the editor:
powerup.gdis a@toolscript (so that its appearancecan be updated based on the sprite_frames property, I guess) but
game_state.gdis not. But thePowerup.abilitysetter wouldpreviously try to use properties of GameState unconditionally.
In
_set_ability, skip_update_ability_name()in two cases:ability_nameproperty and the interact area's action descriptionaren't used in the editor anyway.
F6, GameStatewill not be _ready() at the point where the scene containing the
powerup is added to the tree. So
GameState.questwill be null andthe powerup will always be named after the default abilities:
incorrect if the quest eventually turns out to have custom names.
_set_abilityis called again from_ready(in our standard pattern)so this should cause no behaviour change in-game.
Helps #2353