There is something of Global I don't like

When I input set or +, it always activates the get input. And it makes a major bug in a game I am making.

1 Like

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.

3 Likes

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 +.

2 Likes

If you don’t want the output to update all the time, you can do this:

  1. Disconnect the Global from the logic you don’t want to keep updated
  2. Connect the output instead to a Number block set input to store the value
  3. Connect the Number’s output to your game logic
  4. Get the value from the Number any time you like
5 Likes

You can also use Saves instead of Globals. Works the exact same way, but without the updating.

1 Like

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.

4 Likes

Hmm. Okay :slight_smile:
Thanks for clarifying.

1 Like

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.

image

3 Likes