I have created a new class "ScriptingEngine", extending Reference.
class_name ScriptingEngine
extends Reference
# The card which owns this Scripting Engine.
var card_owner: Card
# Sets the owner of this Scripting Engine
func _init(owner) -> void:
card_owner = owner
I have a node script with class_name Class. Within one function of that script, it creates a object based on ScriptingEngine
var sceng = ScriptingEngine.new(self)
As soon as I try to run my project, it fails with this error
Parser Error: The class "Card" was found in global scope, but its script couldn't be loaded.
This looks like it's a cyclical dependency issue. If I remove the : Card
static declaration from my var card_owner
, it all works fine. Of course it means I don't get the benefits of static typing
What is the way around this? Am I following a bad practice and if so, how should I be connecting these two objects?