Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: MarkHest on January 21, 2016, 04:06:14 pm

Title: [RESOLVED] Show picture depending on digit value in Variable
Post by: MarkHest on January 21, 2016, 04:06:14 pm
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?
Title: Re: Show picture depending on digit value in Variable
Post by: KK20 on January 21, 2016, 04:12:08 pm
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
Title: Re: Show picture depending on digit value in Variable
Post by: MarkHest on January 21, 2016, 04:16:47 pm
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.
Title: Re: Show picture depending on digit value in Variable
Post by: KK20 on January 21, 2016, 04:24:02 pm
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
Title: Re: Show picture depending on digit value in Variable
Post by: MarkHest on January 21, 2016, 05:16:06 pm
How do I get the digits if it's a negative number?
Title: Re: Show picture depending on digit value in Variable
Post by: KK20 on January 21, 2016, 05:25:39 pm
Temporarily convert the number to positive. Repeat the same procedures. Change it back to negative.

:P
Title: Re: Show picture depending on digit value in Variable
Post by: MarkHest on January 21, 2016, 05:37:35 pm
I got it to work! Thanks so much for the help! :haha: