[RESOLVED] Show picture depending on digit value in Variable

Started by MarkHest, January 21, 2016, 04:06:14 pm

Previous topic - Next topic

MarkHest

So I have a puzzle in The Missing Part that keeps track of a number. What I want is to show this number as a picture. This would require a script that can keep track of each digit in a Variable and show a different picture depending on what that digit is.
So let's say I have 10 different pictures, one for each number(0 to 9). I need a script that shows a specific picture depending on what digit in the variable. The number 10 would require two pictures to show since the number has 2 digits. 100 would require three pictures because it's 3 digits... etc...
I will also be able to specify the location of the picture to properly align the pictures to appear as a whole number. (The puzzle variable mainly stays within a 2 digit number and rarely becomes a 3 digit number)

Can this be done?
   

KK20

If it was battle-system related, there's scripts for that.

If it's taking place on the map, can't you just event this instead? It's nothing more than just modulo a variable by 10 and then divide by 10 to get every digit.

523 % 10 = 3
523 / 10 = 52
52 % 10 = 2
52 / 10 = 5
5 % 10 = 5 # At this point, you should check if the number is less than 10

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

MarkHest

January 21, 2016, 04:16:47 pm #2 Last Edit: January 21, 2016, 04:18:28 pm by MarkHest
So how can I get the value of a digit if the number is a two digit number?
If the number is 52... how do I get the 2?

Sorry, I don't know Modulus very well. I'll look into it and see if I can understand it better.
   

KK20

I showed you in my post.

523 % 10 = 3

Modulo is the remainder after dividing.

523 / 10 = 52 with remainder of 3, thus your modulo is 3

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

MarkHest

How do I get the digits if it's a negative number?
   

KK20

Temporarily convert the number to positive. Repeat the same procedures. Change it back to negative.

:P

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

MarkHest