[quote:1l7ubrr1]What I want to do is to use a variable as an object in expressions, for exemple, in my game I have a variables that contain the name of the Hero the player choose for the A slot, another with the chosen Hero for the B slot (etc for C and D). So one variable per slot : ChoixHeroA / ChoixHeroB / ChoixHeroC / ChoixHeroD...
Here what I want to do ( would make 4 events only : one per slot) :
lerp(self.width, (ChoixHeroA.POWER/ChoixHeroA.POWER_MAX)*BarrePOWER_A.LargeurInitiale, 5*dt)
Here what i have to do ( make 40 events : 4 slots x 10 hero) :
lerp(self.width, (HardcoreGirl.POWER/HardcoreGirl.POWER_MAX)*BarrePOWER_A.LargeurInitiale, 5*dt)
Nice graphic and idea for a tower defence
I think your problem is in your object design, so you should be able to fix it by thinking about your heroes a bit differently. Meaning that your heroes share a lot of common attributes and functionality, Like health, they can move around and so on.
Since these things are shared, what you can do is look at all your heroes as being the same object type, except with different values, such as name, damage, movement speed and so on.
So you can solve it several ways. Either you can make one hero and make a unique identifier such as a name variable and use that whenever you have to work with a hero, like this:
//Require:
//Hero.Name
Function Power (Just a function)
Pick Hero.Name = Function.param(0) <--- (Function.param(0) would contain the name of the hero you work with)
lerp(self.width, (Hero.POWER/Hero.POWER_MAX)*BarrePOWER_A.LargeurInitiale, 5*dt) <-- (This wouldn't work in this example. But what is important to notice is that you can replace the "HardcoreGirl" with "Hero" and thereby make it work for all of them. rather than having to duplicate code, which I guess you want to avoid. But the principal is the same."
[/code:1l7ubrr1]
In this case assuming the lerp worked, it would happen to the hero with the name you call the function with.
Another way is to use a family and add all your heroes to the family. Which would allow you to do as show above as well. Just make sure that all shared variables are added to the family object and not the individual heroes.
Again a good idea to use a unique variable such as name even if they are in a family.
Both methods also allow you to use "for each FAM_heroes" if that's what you called the family or "For each Hero" if you just use one sprite for all heroes.
However using Families are in my opinion the way to go as you can better work with each individual hero.
If none of what I wrote here makes sense. I suggest you read about "Functions" and "Families" in the manual. And if I misunderstood you, then ignore what I wrote