Using variable as part of an identifier

Nachorl250

Veteran
Veteran
Joined
Oct 30, 2015
Messages
34
Reaction score
2
First Language
Spanish
Hi!

So in my game I use conditional branches to check the percentage of HP, MP, etc and for example if the result is 50 the game will show a life bar only half full using a Show picture event. The thing is I have several HUD items (HP, MP, Exp, and a couple more) and it takes about 400-500 conditional branches to do it, so if I want to change the scale of the pictures, the position, or anything really I have to do it 400 times, which is very inefficient. 

My idea to solve this was to use the script call $gameScreen.showPicture and then using for example "HPvariable6" as the file name, where variable 6 would store the percentage of HP, so if the variable is 62, the game would look for the picture HP62.png and show it.

Any ideas to use the variable for part of the filename?

Thank you for your attention!


Edit: I might have explained myself badly. What I need to know is a way to combine a variable and text into an identifier. In the case of using "HPvariable6" as the filename, the HP would be static, meaning that no mater what variable 6 contains, the filename will start with HP. So if the variable 6 is worth 32, the filename will be HP32, while if the variable 6 is worth 60, the filename will be HP60.
 
Last edited by a moderator:

lilcooldude69

Veteran
Veteran
Joined
Mar 18, 2012
Messages
33
Reaction score
4
First Language
English
Primarily Uses
you could place it in a common event. as for using a variable as an identifier. you cant really do that via events only what within the interpreter such as variable id or map id. you'd need to make a script. also ive found sometimes there are cases where you're trying to check for 2 variables at a time and to do that with just events youd need to make 2 conditional branches however. with the script option you can check them both at the same time


I.e. if $gameVariables.value(1) == 1 && $gameVariables.value(2) == 3 // checks for 2 variables at a time. check out the help file for operators. they can save loads of time.
 
Last edited by a moderator:

Nachorl250

Veteran
Veteran
Joined
Oct 30, 2015
Messages
34
Reaction score
2
First Language
Spanish
you could place it in a common event. as for using a variable as an identifier. you cant really do that via events only what within the interpreter such as variable id or map id. you'd need to make a script. also ive found sometimes there are cases where you're trying to check for 2 variables at a time and to do that with just events youd need to make 2 conditional branches however. with the script option you can check them both at the same time


I.e. if $gameVariables.value(1) == 1 && $gameVariables.value(2) == 3 // checks for 2 variables at a time. check out the help file for operators. they can save loads of time.
Thank you very much for helping!


However, I don't think you got what I meant. I know the most efficient way is to do it via Script calls, but what I need to know is a way to combine a variable and text into an identifier. In the case of using "HPvariable6" as the filename, the HP would be static, meaning that no mater what variable 6 contains, the filename will start with HP. So if the variable 6 is worth 32, the filename will be HP32, while if the variable 6 is worth 60, the filename will be HP60.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
var filename =  [COLOR= rgb(39, 42, 52)]"HP" + $gameVariables.value(6)[/COLOR]


[COLOR= rgb(39, 42, 52)]$gameScreen.showPicture ( ... using filename in the appropriate position ...)[/COLOR]
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,867
Messages
1,017,061
Members
137,575
Latest member
akekaphol101
Top