I have a couple of functions that I would like to be able to call from any of my scripts that all are attached to different noes. Is there a way to define something like a global function, or add a method that will be inherited by all nodes?

  • xyz replied to this.

    m0bamb1 Create a class and declare methods as static. They can be called from anywhere using Class.method()

    class_name MyFunctions
    extends RefCounted
    
    static func foo():
    	print("foo")
    	
    static func bar():
    	print("bar")

    The above script class doesn't have to be attached to any node. Just save the script and static functions will be accessible globally.
    So from any other script simply do:

    MyFunctions.foo()
    MyFunctions.bar()