0 Favourites

[Feature Request] Global Variables

  • Hi!

    I think having a better organization within Global / Local variables would be great.

    For now, every time I need to use one I have to go through a big list.

    Maybe could be organized into sub-categories for better readability?

    Thanks!

  • I wouldn't mind having global variables be located somewhere other than on the event sheet, and organizing them into categories would be great. Hadn't really thought about this before, but now that I do it would be awesome.

  • I put all the Global vars into a separate event sheet and use comments to separate the various differences/uses. Makes finding/managing much simpler.

    Not a substitute for your suggestion, I know, but a stop-gap alternative..

  • I do the same, separate sheet with comments, But I find it difficult when it comes so adding them via System - etc. All the variables are listed by alphabetical order. Perhaps could be via sub categories so it could match the comments/name for each category in the var sheet.

  • Personally for Globals. I like to make a Dictionary set it to global. Then make my globals in that object. I personally don't like cluttering up the variable scope with lot's of var globals.

    So there you go. Proper globals associated with a class rather that floating in memory space.

  • jayderyu, that seems like a great suggestion. Ill be trying that

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • jayderyu

    That's a good suggestion. I still like having certain values as normal globals so I can tweak them easily during development. Also, the one drawback with the dictionary is a lack of auto-fill. However, there are a lot of less important global values that would be much better off in a dict like you suggest.

    Another approach is to create a global sprite, and place it on a global layer. Then, add instance variables to it. This way you don't have to worry about mis-spells, you have auto-complete, and you still avoid cluttering up the top-level scope with normal globals.

  • Global variables make sense, for constants, and for other things like character names, location, play time, etc.

    For a RPG Character Database it is global as the info is accessable at every point in the game, now game dialog can be local as it's only called locally not globally.

  • This gets asked around some times. Here's two of my posts on the subject:

    Post 1

    Post 2

    also see this and this (both in the same thread), where I suggest cosmetic (aka, interface-only) solutions to the problem.

    Keep in mind that the solution only involves changes to the IDE, the engine itself need not be affected. In fact, since each variable can only be in one group (a tree structure), all the engine has to do is concatenate the parents to get the final variable name. So player.ship.resistances.fire could be converted to "playershipresistancesfire" on exporting. It seems pretty simple to me, but only Ashley can say with certainty how hard it would be to change the IDE (I hear it's a bit painful).

    While the solution above applies to instance variables, there's no reason a similar scheme can't be applied to global/local variables as well.

  • Personally for Globals. I like to make a Dictionary set it to global. Then make my globals in that object. I personally don't like cluttering up the variable scope with lot's of var globals.

    So there you go. Proper globals associated with a class rather that floating in memory space.

    I like this solution. I'll be using it for now. Seems obvious now that you say it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
173 28,546
Rich's avatar
Rich
Unread sticky
150 20,722
Crow in the Snow's avatar
Crow in the Snow
Unread hot topic
0 Favourites
C3 Architect Request list
125 12,730
jayderyu's avatar
jayderyu