[SOLVED] Apply an action to all the children of a structure

How do I… apply an action to all the children of a structure?

I’m setting a xp bar for levelling up in different abilities.
Screenshot (87)

All the abilities are global variables in an array like this:

Depending on the level of the ability (under 50, between 70 and 79, for example) the xp needed to level up varies, so the maximum value in the bar, like this:

Is there a way to apply the same action to every single ability inside the structure “ability” without specify every single ability?
Something like:

the global variable db[1].ability.[allthechildren] < 50


Hi @jordi82

Since the action changes the values of the bars and not the values of the variables, you can loop through the bar objects instead of looping through the array children.


  • Add a instance string variable to each bar with the name of the child variable (I’ll call it id). For example add instance string variable (Iid = “Ball_Control”) to the BallControlBar object etc…
  • Put all the bars objects in a group (I’ll call it bars_group)

For each “bars_group”

  • db[1].ability.[BallControlBar.VariableString(id)] < 50 → Change value of bar to X
  • db[1].ability.[BallControlBar.VariableString(id)] >= 70 → Change value of bar to Y
  • etc…

Hi @insein ,

first of all thank you for your response!
I think I’m missing something because, after setting the variable like this:

I can’t call it.

What am I missing?


My mistake, I answered on my phone and I had mistakes with my suggestion. I guess I’m not used to answering on my phone, sorry about that.

The method is still the same.

  • add instance string variables to all the bars. The idea is to link the bars to their respective variables in the array. Instance variable’s name is “id” and the string is the same as the variable’s name in the array (Hope my explanation is clear).
  • put all the bars in a group called “bars_group”

The events should be like this:

Ah, okay! Now I understand the logic (and it works)!

Thank you very much!

1 Like

And there would be a similar solution to “link” a “BallControlPlusButton” to add 100 only to his “BallControlBar” and so on for all the other Bars and Plus Button?
I created an event:
PlusButton_Group is clicked → Change value of Bars_Group: add 100

but of course it changes ALL the bars value altogether.

Yes, the buttons should have the same id as their respective bars to link them together.

You also need to add this condition to your event:
String variable “id” of bars_group = buttons_group.VariableString(id)

Perfect! With 3 “simple” events I completed the level up structure of my game.
Thank you for the solution, but especially for helping me understand the mechanism!

1 Like