Is there a way to shorten long naming functions with alias?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ondesic

I call get_tree()_get_nodes_in_group() all the time.
Is there a way to assign an alias to this so I could type maybe GN() to mean the same thing?

:bust_in_silhouette: Reply From: Zylann

You cannot do that globally, but you can write this in the script where you use it:

func GN(group):
    return get_tree().get_nodes_in_group(group)

If you want it globally, you could define an auto-load script named “Util” that contains the function above, so you can write this for example:

var nodes = Util.GN(group)

Personally, I don’t think it’s worth the hassle though.