Custom class as a global storage

Godot Version

4.2

Question

If i define a class without initialising it nor creating an instance of it so that it acts as my global storage (not through an autoload), is there a way to make that class to show up in the debug?

Example:

Starting scene script

extends Node2D

func _ready():
	print(Basket.Veggie)
	Basket.Veggie = "Cucumber"
	print(Basket.Veggie)
	pass

test_class.gd

class_name Basket

var Fruit = "Orange"
static var Veggie = "Tomato"

This will print out both “Tomato” and “Cucumber” but i cannot find a way to track this class in debug, is there a way to track the changes of classes like these without spawning print() everywhere?

I’m not quite sure what you want to “track”, but perhaps you should create your signals in the global class and call them to change global class variables

If you can explain your goal, maybe I can help you.

I want to track the variables in that class whenever i hit some breakpoint during a debug process or somehow make godot to show this class in the remote tab.

The godot does somehow ties this class_name between scripts without any initialisation so i was wondering if i can track the variables of that class.

I don’t use debugging much (I sin), but you could try instead of creating a class from scratch, make it a child of Resource/RefCounted. Perhaps in that case Godot will recognise it

I also don’t fully understand what the problem is with initialising a class if you can track essentially without it… nothing?

As a repository you can still try to use JSON files. I think that’s all the knowledge I have in this area

I don’t want it to be an instance tied to a certain scene - i want it to be a global storage of variables.

Then I think the only option is to use autoloading in the project settings.

2 Likes