0 votes

I am trying to write a custom copy-data function. I would like to give it a stronger typing so I can get the auto-complete. In other words, I have this:

# res://MyClass.gd
func copyFrom( other ):
    value = other.value
    # ...

but would like this:

# res://MyClass.gd
func copyFrom( other : MyClass ):
    value = other.value
    # ...

I have tried a few things with these frustrating findings:
It looks like you can't preload a class in it's own file.
It looks like load results can't be made const, so they can't be used as a type, (I think?)
I would add class_name but that seems to give me all kinds of circular errors if I try to use the file anywhere else.

There may not be a way to do it right now (3.1), and that's fine, too. I just would like to know the answer if it is possible.

asked Dec 18, 2019 in Engine by Aristonaut (30 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.