Variable Confusion

HexMozart88

The Master of Random Garbage
Veteran
Joined
May 15, 2016
Messages
1,783
Reaction score
3,193
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
29,513
Reaction score
6,867
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,783
Reaction score
3,193
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
29,513
Reaction score
6,867
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,783
Reaction score
3,193
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
38,792
Reaction score
12,219
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 Profile Posts



Almost 5 am.. and I decide to put up a Youtube video instead of sleeping. It's strangely addicting! :kaoswt:
If I survive the pandemic without 2nd degree obesity, I'll celebrate. The stress I have to deal with at work is so insane my candy consumption has increased by 400% just to help me survive the day sometimes.
I don't like calling my daily stuff coronadailies... anyone a better suggestion?
Well, looks like I need to build myself a quest system. Or really just a system for "Helpful voices" to talk to the player. I'm sure nothing will go wrong listening to them.... They're "helpful". :LZSwink:

Should be pretty easy with PIXI just letting me write all over the screen. :LZSexcite:
I'm starting to think I just dont like anime since the last one I enjoyed was none of them.

Forum statistics

Threads
95,595
Messages
930,339
Members
125,902
Latest member
bootlegtexas
Top