Use variable in condition syntax (Answered)

Hi Good day!
I have been using a number of structure variables that have similar child variables. In this case, hero stats. Is there some way to call them with just one condition using a key variable?

An example I’m currently working on goes thus:

If a hero is at level 10, said hero gets boost to a stat
The new stat is then saved under the hero’s stats variables.
I currently have four heroes with their own structure variables for their stats.

Saves are managed with a separate event for each hero.
Is it possible to use one condition that can be made to apply for whichever hero is being used by using an id or reference variable? Or is this not possible at all?

Attached is a screenshot of the current separate conditions method
and an attempt to use a single condition.

Condition syntax 2024-07-20 08_09_00-Greenshot

Personally, I’m a bit confused on what your asking.
I might just not have enough of a coding background, but for the sake of getting this resolved, could you explain again in different words?

So, yes and no.

You cannot dynamically build the name of the parent variable (So you cannot do Hero+anything to get Hero01). You would need to stick those structure variables as a children of a static parent variable, like “Heroes”. Then you could do Heroes[“Hero”+HeroSelect] to get Heroes.Hero01 if HeroSelect=01.

Also note that the Variable() expressions are deprecated and you cannot add them to new events.

2 Likes

I’m sorry if it was kinda confusing… uhm… okay… I’ll try to make it clearer, I hope.
In my project, there are 4 heroes. Each are assigned an id variable, 1, 2, 3, and 4 accordingly.
Each have stats, health, attack, speed, etc. recorded as child variables under a parent variable.

I’d like to be able to call such stats using only 1 condition instead of separate conditions for each.

for example,
condition = action
if hero1 gets to level 10 = hero1 gets bonus according to hero1 bonus variables
if hero2 gets to level 10 = hero2 gets bonus according to hero2 bonus variables
… and so on for each of the (currently) 4 heroes.
This would require 4 separate events for everything related to the hero stats.

I’d like to simplify this like so:
If hero(insert id variable here) gets to level 10
= hero gets bonus according to hero(insert id variable here) bonus variables

So I think basically I’m trying to use a sort of expression syntax or something on to the condition field. Though if it’s not at all possible, it’s okay, I’m not really stuck or anything, it’s just for simplification purposes.


edit:
@Silver-Streak Ah yeah, that one. Dynamically build the name. I was already beginning to think it wasn’t possible at all. So I guess it really wasn’t.
Thank you very much!