[Request] Groups for Global Variables

0 favourites
  • 13 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.
  • When there's a lot of them, it would be great to segment them, or be able to hide them so that you can focus on events.

  • I generally put them in their own event sheet for that reason. But yeah, it would be nice for variables in a top level group to be global.

  • +1to that

  • Variable nesting in general would be super useful

    Also, instance variables could benefit from this grouping as well.

    I don't get why this isn't already implemented, it seems so easy, especially considering it's only a visual thing with no impact whatsoever on the game engine.

    Here's an use case for variable grouping: a medieval RPG, where attacks can deal different types of damage:

    • Piercing
    • Slashing
    • Blunt
    • Magical
    • Siege
    • Elemental: Earth
    • Elemental: Air
    • Elemental: Water
    • Elemental: Fire

    Then I have different ways to mitigate damage:

    • Damage treshold (flat damage reduction)
    • Damage resistance (% reduction)
    • Evasion (% chance to completely negate damage)

    And for attack I would need:

    • Base damage (used as a base for calculating)
    • % increases and decreases
    • Flat increases and decreases
    • Effective damage (all bonuses and penalties applied)

    So I have 9*4=36 variables for attack

    9*3=27 variables for defense

    for a total of 63 damage-type related variables. For each "player" or "enemy" type. You can see how this can quickly become unwieldy with the current system of a flat list of variables.

    Under the current system, you end up with variables named attack_damagetype_blunt_basedamage littered all over your objects, and you cannot simply "hide" them or collapse their group.

  • What I usually do is put my globals at the top of whatever event sheet I'm using (I don't always opt for a dedicated sheet, depends on the game) and sort them by using empty groups for categories (Player, Enemy, UI, Misc, Debug, etc...), with separate comments for any var that need additional explanation. Visually, I love this.

    Early on, I wanted to be able to put globals in a group, but, actually, at this point I'm fine with the way it is.

    Fimbul

    Doesn't construct already do variable nesting? Like, if I drag a global into a group, it only functions in the scope of the group. Or am I misinterpreting your meaning here?

    As for instances vars...I've never had a need for that many, but...yikes. Yeah, if I was in that situation, I would want folders too...

  • Doesn't construct already do variable nesting? Like, if I drag a global into a group, it only functions in the scope of the group. Or am I misinterpreting your meaning here?

    No, you got that wrong. I don't mean variable scoping (this is already implemented, like you said, and works fine), just variable nesting (which is just cosmetic) - similar to how javascript objects are accessed:

    player.equipment.armor.blunt.pctResistance

    As for instances vars...I've never had a need for that many, but...yikes. Yeah, if I was in that situation, I would want folders too...

    Yes, you got that correctly. What I wanted is a solution like this inside the instance variables pane (the image is just an example I took from an e-commerce widget thing, ignore the text and focus on the functionality only):

  • +1 for that. Structure is everything!:)

  • SOmetimes number of global variables grow considerably and it becomes a chore when trying to referance them in some way, ie you use the dropbox to reach them in editor and it slows you down. Would be nice if groups of global variables could be referenced accordingly too.

  • Tagging Ashley

  • Globals are currently defined as a variable at the top-level, so naturally variables in groups are local variables, which I also think is a useful feature by itself. I'm not sure we could easily change this right away. You could try spreading them over different event sheets.

  • Ashley: But can't we have a simple cosmetic solution for global/local/instance variables, like the current "folders" for objects (which don't actually do anything)?

    Also, if possible, could we have this:

    ?

  • It's not simple. Groups already do that, and they are not a simple editor feature, and it would be silly to waste time re-inventing them for a different cosmetic purpose.

    I don't want to change how scope works, because it's usefully analogous to how it works in real programming languages.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok. What about instance variables, though? There are no groups there, and no way to "hide" them by using different sheets. IMHO a simple collapsible optgroup list would suffice.

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