Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Using variable as part of an identifier

Nachorl250

Towns Guard
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!
 

FlipelyFlip

Villager
Xy$
0.00
Heyey,

I have made you a plugin for an easier use. With this Plugin you only need to calculate the percentage of the HP, MP, etc and pass it to a variable. Then use the plugin call of your wish, define the ID of the Picture you want to change and add $gameVariables.value(id). Replace id with the id of the variable. This script then automatically stretches the picture to the given percentage. So you only need 1 graphic for the background gauge and one for the gauge itself and this plugin to make it visible. The rest is done via your event (:

Link to the Plugin

~Flipely
 
Top