Basically what I would like to achieve is something like this var biz: GDScript = get_gdscript() so the variable can be used as a function argument. This var biz: GDScript = MyClass already works, but with this approach I don’t think there is a way to get a class dynamically.
I was trying to make multiple classes inheriting each other where the parent class has a method that doesn’t need to be overridden by its children but handles some logic depending on which class the method was called on. For example:
class_name Parent
extends Node
func get_gdscript() -> GDScript:
return Entity # replace with actual way of getting class
func create() -> Parent:
print("Class inheriting Entity was destroyed") # some logic that is the same for all children
return get_gdscript().new()
But I realised that I can just seperate it out into two functions, one for the general logic and one for the child-specific logic:
class_name Parent
extends Node
func create() -> Parent:
print("Class inheriting Parent was created") # some logic that is the same for all children
return _create()
## overridden by children
func _create() -> Parent:
return Parent.new()