- Edited
I've run into yet another weird instance of circular references in gdscript. I'll probably put in an issue if I can figure out how to make a minimal project out of it, but I thought I'd look for input first.
I've got an inheritance structure that looks like this.
Entity
Creature
Player
Each entity, including the player is a Node2D, child of the Dungeon (tilemap). When I check (in Entity) whether an object is an instance of Dungeon, it causes parser errors. Note that this is while running the project from the editor, but the project never reaches the execution stage.
func _ready():
var my_parent = get_parent()
if my_parent is Dungeon:
pass
SCRIPT ERROR: Compile Error: Identifier not found: grid_position
at: GDScript::reload (res://player.gd:36)
grid_position is a parameter of Entity, which should be inherited by Player. The double-inheritance can't be traced by the parser, but it can be traced by the editor, which has no problem autocompleting the parameters. There are no errors in the editor.
Now, if I just use a parameter to determine whether it's a dungeon, everything works fine.
func _ready():
var my_parent = get_parent()
if my_parent.get('is_dungeon'):
pass
If anyone is really interested, the code is here, but it may give you a headache.
I bet c# doesn't have these issues.
Edit: The problem is likely due to a similar line in Dungeon checking if an object "is Entity", causing a circular reference.