How to make script of a scene use variables or functions of global singleton in visual script?

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


How can i use variables, stored in an autoload globals singleton script with other visual scripts?

:bust_in_silhouette: Reply From: SnapCracklins

Take whatever the name of your global GD file is, load it in Autoload in the Project Settings, (you will also need a Node of some sort to autoload as well, likely whatever “System” or Scene-change type handler you are making) then you can call whatever you need to from that file using that name then a period for what you are calling.

So let’s say you have a file that is called and you autoload it at start. It has this script:

var roundTime = 10

func onRoundEnd():
     ## do something here

So to call those in your other scripts, you would put:

Global.roundTime = 20

Just be aware to change these values you need to call them directly (like I just did above). You can’t store their value in a local variable and then change that to alter the global.

I know how to do it in godot script.
there i can do it just by having the script in autoload.

I specally want to know to do it in visual script.

Drachenbauer | 2022-04-02 20:12