Class_names, class, outer and inner classes

Godot Version

4.2.2

Question

currently making an inventory in game, nothing fancy but i realized halfway through i could use inner classes and that those inner classes would be attached to my class name, letting it be referenced in scripts that extend my class name.

Trying to understand the entirety of classes in godot. ive tried reading some docs and looking at other peoples post but havng trouble understanding the basics with how to use class and class_names in gdscript.

so far im doing stuff like this but its not really working. please let me know what im not understanding and how i should be looking at inner classes and class_names

script 1

       class_name weponlist
@export var itemlist: Array = ""

class sword:
@export var title = "" or @export var title1: String =""

class shield:
@export var title = "" or @export var title2: String =""```

script 2 

```Extends sword 
#code describing and giving more detailed info on class```

Can’t extend a class, nor export values from it. class creates a very limited type within the script, can be used instead of dictionaries in some cases but cannot be exported.

class_name registers a script globally as a type, every other script will understand this type and the editor can display it’s properties.


class_name is more generally useful, class is good if you have a bunch of private data in a complex type.

1 Like

thank you !