I'd like to know if it was possible to consider variable names as strings, in order to make some operations easier and avoid duplicating conditions.
Sometimes like this:
<img src="https://dl.dropbox.com/u/39121175/ManipulateVariableNamepng.png" border="0" />
This would allow to avoid duplicating conditions "if GunType=1" "if GunType=2" "if GunType=3" etc. (I don't have many GunType but still, it would be more... clean)
It worked with animations (anim1 anim2 anim3) since the animation name is already considered as a string, so I just had to change the number without converting the variable name into a string. It was extremely convenient, I must admit.
In the example above, I turned the variable name into a string with the str() function but... I didn't work (logically since I converted the variable itself, I suppose). How to "manipulate" a variable name like if it was a string? Is it possible?
Thanks in advance!
Rag' <img src="smileys/smiley32.gif" border="0" align="middle" />
You can choose to Text when creating Global Variables, is this what you want?
Edit: Oh you meant variable "names" no values, my bet.
Develop games in your browser. Powerful, performant & highly capable.
If you store the values in a dictionary you could do something like:
<img src="https://dl.dropbox.com/u/8367729/construct/pics/dictionary.png" border="0" />
I love to use it for change weapons, for example.
Weapon instance have the variable called by "type" and it's set to be text. Also, you can make other variables like "damage" for each different damage you want, or simple increase it like you did for the weapon.
Inside the animations, I did them calling each one as weaponN, where the N is a ordinal number.
When the player change his weapon, for example, of the 1 to the 2, I just set it looping:
|Keyboard - "A" pressed:
|__set weapon.variable.type add +1;
|weapon - variable.type > 10:
|__weapon.variable.type = 1;
|system - every tick:
|__set weapon.animation to "weapon" & weapon.variable.type;
|__set weapon.variable.damage to weapon.variable.type;
Thanks all of you for your answers, I think I've found what I was looking for :)