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]
[code:2fnu5ayr]if monster.Shield>0 then MyVar="Shield"
else if monster.Armor>0 then MyVar="Armor"
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?
I am not sure this is possible, nor do I know of any already existing plugins for it.
You would use an array for this, or even a dicitionary.
You could use a container which would group your "monster" object with a Dictionary object (say "monsterDictionary"). So each instance of "monster" would have its own dictionary.
Develop games in your browser. Powerful, performant & highly capable.
Thank you all for the replies. Using a dictionary with monster oblect might be a good idea, I'll give it a try.