[Request] Groups for Global Variables

Discussion and feedback on Construct 2

Post » Wed Mar 19, 2014 3:57 pm

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.
B
17
S
4
G
4
Posts: 143
Reputation: 4,004

Post » Wed Mar 19, 2014 3:59 pm

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.
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,749

Post » Thu Mar 20, 2014 2:51 pm

+1to that
B
39
S
13
G
6
Posts: 148
Reputation: 5,384

Post » Thu Mar 20, 2014 3:55 pm

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.
B
36
S
8
G
8
Posts: 532
Reputation: 6,903

Post » Thu Mar 20, 2014 5:58 pm

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... :shock:
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Thu Mar 20, 2014 6:11 pm

TiAm wrote: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
TiAm wrote: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... :shock:

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):
Image
B
36
S
8
G
8
Posts: 532
Reputation: 6,903

Post » Thu Mar 20, 2014 6:21 pm

+1 for that. Structure is everything!:)
Image
Check out our start-up and configure your own helmet in true 3D.
B
44
S
11
G
11
Posts: 1,154
Reputation: 9,978

Post » Fri Mar 21, 2014 11:05 pm

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.
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Post » Thu Mar 27, 2014 2:08 pm

Tagging @Ashley
B
17
S
4
G
4
Posts: 143
Reputation: 4,004

Post » Thu Mar 27, 2014 2:14 pm

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.
Scirra Founder
B
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Centra, Yahoo [Bot] and 5 guests