Variable Confusion

HexMozart88

The Master of Random Garbage
Veteran
Joined
May 15, 2016
Messages
1,879
Reaction score
3,349
First Language
English
Primarily Uses
RMVXA
I'm trying to show the enemy's health with pictures, but I keep having some issues. 

Screenshot (58).pngScreenshot (59).pngScreenshot (60).pngScreenshot (61).pngScreenshot (62).png


This is my common event. 



The problem:

Screenshot (63).png


I had set the variable to be 100 originally, and when I take away ten, the wrong digit is being assigned. When I press F9, it says that the health variable is set to 90, but when I look at the variables I set for each number, it says that the hundreds column is equal to nine and the rest of it is equal to zero. But I thought it should work because of the way math works.  

Please tell me what I am doing wrong. 


It seems to be doing this with every number that goes into another digit. Whenever the first number goes to zero, it automatically resets to 9. 
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
if the wrong numbers appear, then something in the script you're using to split the numbers is wrong. I don't know how that split command works, but I suggest checking its syntax - if you really want to do it that way.


Because my suggestion would be to drop the script and use a series of control variable command. Using the modulo operation should make the split easy


1) Hundred digit: Base number divided by hundred (reminder is automatically dropped as the variables are integers)


2) tens-digit needs two operations: base number modulo 100, that result divided by ten


3) single-digit needs one operation again: base number modulo 10.
 

HexMozart88

The Master of Random Garbage
Veteran
Joined
May 15, 2016
Messages
1,879
Reaction score
3,349
First Language
English
Primarily Uses
RMVXA
It works for the enemy HP, but when I go to do the same for the player, the hundreds digit doesn't show up at all. 


EDIT: Went into F9 again. That sets the variable to 44 for some reason. 
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
make sure that all your scripts are configured correctly.


Let me guess: you used Yanfly's Message system but never configured it? Because the default configuration of that script uses two variables in the area of 20+ if I remember correctly, and changes them for its own purposes.


If that is not the cause, please show screenshots of your current event setting the numbers (no need for the long picture checks, only the place where the numbers are calculated)
 

HexMozart88

The Master of Random Garbage
Veteran
Joined
May 15, 2016
Messages
1,879
Reaction score
3,349
First Language
English
Primarily Uses
RMVXA
Actually, no. I just figured out it was because the test character I used has over 4000 HP, so I just set it so that she starts at level 1 instead of level 90 and it worked. 
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
The problem is that you're pulling your number apart from left to right and assigning them to the variables from left to right.  So if you have 3 images and the HP is 90, var 1 will be 9, var 2 will be 0, and var 3 won't have anything, so will probably default to 0 (because there's logic when checking the value of a variable to say if it's undefined, make it 0).


In that script call, before assigning the digits to variables, you need to add any leading zeros, so the units and tens will actually get assigned to the variables for units and tens, not for tens and hundreds.


This will also introduce another issue - if the HP is 90, doing the above will get you 090.  So you should wrap your list of conditional branches for each display into another conditional branch checking to see that it's high enough to show that digit.  For example, "if HP > 99, do all the conditions to see which hundreds figure to show, otherwise erase the picture for the hundreds figure", then "if HP > 10, do all the conditions to see which tens figure to show, otherwise erase the picture for the tens figure".  You shouldn't need to do it for the ones, as 0 HP would be game over, and if it shows at all, 0 is probably okay in this case.
 

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,864
Messages
1,017,056
Members
137,573
Latest member
nikisknight
Top