When I input set or +, it always activates the get input. And it makes a major bug in a game I am making.
Yes, Globals are a bit different than most behaviors in that every time you change one, all other globals are notified. That’s by design, and can be very useful, but it can also lead to game logic bugs if you are not expecting it.
You know what would be cool. It would be a setting in Global that whether or not if you want Get to activate when you do set or +.
If you don’t want the output to update all the time, you can do this:
- Disconnect the Global from the logic you don’t want to keep updated
- Connect the output instead to a Number block set input to store the value
- Connect the Number’s output to your game logic
- Get the value from the Number any time you like
You can also use Saves instead of Globals. Works the exact same way, but without the updating.
I wouldn’t say the exact same way - save blocks store the value on the player’s computer, so it is still available when they play the game in the future.
They are similar in that they are globally accessible, so you’re right that you can sometimes substitute one for the other.
Thanks for clarifying.
Globals work so you can trigger all the same globals with the newest value. Very useful for keeping numbers updated everywhere or just trigger events at the same time.
“Set” and “+” outputs for ALL Globals, but “Get” just outputs for that one Global.
If you dont need this type of exchange, you could use messages or set it aside in a number to be used later. Below is an example.