How to name my classes?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Elis

Hi!

How can I name my classes so that I can get them as string with a function?
I see two problems: either I don’t know how to properly name my classes, or I don’t use the right function/method to get the class as string.
This is what I do for now, which outputs “Reference”.

class alpha:
       var v1
	   func _init(v1):
		 self.v1 = v1

var a = alpha.new(1)
print(a.get_class()) ---> Reference
:bust_in_silhouette: Reply From: estebanmolca

https://forum.godotengine.org/46057/how-to-get-the-class-name-of-a-custom-node

According to the answer in the last link, your example would look like this:

class alpha:
       var v1
       func _init(v1):
         self.v1 = v1
      func get_class(): return "alpha"

var a = alpha.new(1)
print(a.get_class()) # ---> "alpha"