Important to note that any script you add to Autoload will create a Node to attach it to when you run, then child that Node to the root. There's no way to get around Nodes with Autoload.
In 4 you can have a class with static variables that doesn't inherit from Node (it will still inherit from Object *RefCounted (Thanks xyz)), name it, and then access its static/const members from anywhere.
class_name StaticStuff
static var some_static_var := 1
const some_const_var := "I'm a const!"
enum DangerousTallBirds {
EMU,
OSTRICH,
CASSOWARY,
RHEA
}
enum {
YOU_CAN_ACCESS_THESE_TOO
}
static func static_func() -> void:
print("I have been called.")
func non_static_func() -> void:
push_error("How did you get here? Leave at once!")
accessed like so:
extends Node
func _ready() -> void:
print(StaticStuff.DangerousTallBirds)
print(StaticStuff.some_static_var)
StaticStuff.some_static_var = 300
print(StaticStuff.some_static_var)
print(StaticStuff.some_const_var)
print(StaticStuff.YOU_CAN_ACCESS_THESE_TOO)
StaticStuff.static_func()
#StaticStuff.non_static_func()
#^Error: Cannot call non-static function "non_static_func()" on the class "StaticStuff" directly. Make an instance instead.
var instance := StaticStuff.new()
instance.non_static_func() #Can call off of instance