Is it possible to access object's instance variable by its name?
Say I have an object monster with instance variables param1, param2, param3, [...] param10
I want to do something like this
for x=1 to 10
monster.Variable("param" & loopindex) = random(1000)[/code:2fnu5ayr]
instead of
[code:2fnu5ayr]monster.param1= random(1000)
monster.param2= random(1000)
monster.param3= random(1000)
monster.param4= random(1000)
...
monster.param10= random(1000)[/code:2fnu5ayr]
Another example:
[code:2fnu5ayr]if monster.Shield>0 then MyVar="Shield"
else if monster.Armor>0 then MyVar="Armor"
else MyVar="Health"
monster.Variable(MyVar) = // some complex calculations here to apply damage to monster's shield or armor or base health[/code:2fnu5ayr]
I'm guessing there is no built-in functionality for this.. Maybe there is a plugin or some workaround?