Object Node as an Autoloader/Singleton?

Godot Version

4.3

Question

I have an autoloader script that uses my print_all() function that prints all variables in the specific script I am in and then a hi() for a print(“hi”).
However I don’t want to do:
const Utils = preload(“URL”)
Utils.hi()
Utils.print_all(self)
As I feel that defeats my goal of going for simplicity. Instead I’d love to just write:
hi()
print_all(self)

So, I understand it may be inadvisable(thanks Claude) to edit the Object class but, would these functions truly cause an issue?

An Autoload does not require the first line defining the type const Utils. Instead Utils would be automatically accessable.

Make sure you understand what “editing the object class” entails; You would be making a custom fork of the engine.

1 Like