I'd like to create a script with a couple of references and simple methods that I can call from any node in my project.
For instance, in my projects, I tend to create a Main node that everything else is a child of, and, in each script, to define an "abbreviated self.name" variable called
sn that I can quickly drop into
print() calls so that when I'm testing, I can see where each printed message came from.
At the moment, I'm pretty much putting a copy of this code into every single script, which is far from ideal. It feels extraneous to have to tell every script where Main is, and if I ever want to adjust that initialise() function, I'll have to copy the changes into every script in my game. It would be ideal to be able to get every node to inherit the code by default, but there doesn't seem to be an elegant way of achieving that.
I've seen others asking similar questions before, and the suggested solution was usually either "define a custom class for every single node" or "modify the Godot source code." Surely there must be a simpler way?