why does putting global variables in a Group change their scope?

0 favourites
  • 5 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • I have SOO many global variables and I'm trying to organize them. I already have them in their own separate event sheet. I would LOVE to be able to put them in collapsible Groups, however when I do this, they all become Local Variables - which makes no sense to me.

    Any suggestions how to best organize them?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • It makes sense, you can deactivate groups. If you have a global variable in this group, it would break your game.

    For the organization of your variables I can not really help. I try to avoid global variables if it's possible and use instance, family variables and local variables instead.

  • Scope is designed to work like it does in programming languages, and in fact actually helps you to organise variables too. If you put a variable in a group (or sub-event) it is only accessible to events in that group. So in many cases you can move a variable to just the section of events that uses it, and it avoids clogging up the project with more global variables. If you enable the "static" option for local variables then you get a locally scoped variable that remembers its value like a global variable. So you can organise variables so they're only scoped where they're used and the top-level global variables are just the few variables that truly need to be accessed by events all over the project.

  • Asmodean globals are pretty hard to avoid when you are working with multiple layouts. I guess it depends on the complexity of the game.

    but yeah I forgot about the deactivating thing, yeah that would indeed mess things up.

    I just want a way to be able to categorize globals and collapse them so I can find them without having to remember their name. So what I usually do is use a descriptive naming convention like:

    Game_LevelDifficulty
    Game_StoryModeFlag
    Game_MissionFlag
    Player_Level
    Player_CurrentXP
    Player_Health
    Player_Money
    
    
  • Ashley

    If you enable the "static" option for local variables then you get a locally scoped variable that remembers its value like a global variable. So you can organise variables so they're only scoped where they're used and the top-level global variables are just the few variables that truly need to be accessed by events all over the project.

    good tip thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)