# Gw Temp

## Tutorial - 'Dividing one (3 digit) number into 3 variables' by Guest

An item about RPGMaker 2000 posted on

### Blurb

A variable-splitting tutorial showing you how to extract the digits of a variable and put them into several variables.

### Body

Hello, i am mokkan and I am here to show you how to divide a number into three variables, if you don't know what i mean look below---------------------------------------------:Number = 264
:Var. hundreds = 2
:Var. tens = 6
:Var. Ones = 4
So there is less conditional branches.
------------------------------------------------------------
This tutorial tells you how to make it so (say you want to show what something says in numbers and it goes up to 100.)
Instead of doing 100 conditional branches. This will let you do about 27. So lets get started.
------------------------------------------------------------
What you need to know:
-Variables (math)
That's quite it.
------------------------------------------------------------
Now the first thing you do is make these variables.
-Hundreds
-Tens
-Ones
-Copy of Total
-10
-100
Got em'? Now here comes the hard part, get ready.
------------------------------------------------------------
I actually picked this skill up from Legacy 001 in his awsome game, Naufragar: Crimson
Here it goes.
------------------------------------------------------------
First-
Set the 10 var to 10. You do this because this variable will be multiplied by the tens number. (say the total number is 666 >:D. The 10 variable will be multiplied by 6 because that is the number in the tens place.)
------------------------------------------------------------
Second-
Set the 100 var to 100. (same reason as you set the 10 variable to 10.)
------------------------------------------------------------
Third-(we're getting the # for the hundreds)
Copy of Total set the "whatever you want" (it can be variable or hero HP, MP etc.
Then divide Copy of Total by 100 (NOT THE VARIABLE!)
Then set variable Hundreds to Copy of Total.
(And now it will equal the hundreds place number.)
Formula-
number = 234(say it's this number) / 100 = 2 (rpg maker doesn't do remainders, except for modulus.)
------------------------------------------------------------
Fourth-(we're getting the # for the tens place)
Copy of Total set to (the same number the hundreds was set to)
Var. 100 * Hundreds var. = (if the number was 578) 500
Var. Copy of Total - Var. 100 = 78 (if the number was \\)
Var. Copy of Total / 10(NOT THE VARIABLE!!!!) = 7 (remember, no remainders)
Var. Tens set Var. Copy of Total = 7 (if the number was \\)
------------------------------------------------------------Finally-(this is to get the ones!!!!!)
Var. Copy of Total set (the same number that was set by tens and hundreds)
Var. 10 * Var. Tens = 70 (if you saw the previous example number.)
Var. Copy of total - Var. 10 = 508
Var. Copy of total - Var. 100 = 8
Var. Ones set Copy of Total = 8!!!!!!!!!!!!!!!!!!!!!!!
------------------------------------------------------------
That's it!!!!!!
And if you're not sure than here's the script.

<> Variable Oper: [????:10] set 10
<> Variable Oper: [????:100] set 100
-------------------------Get Hundreds-----------------------
<> Variable Oper: [????:Copy of Total] set ((((whatever))))
<> Variable Oper: [????:Copy of Total] / 100
<> Variable Oper: [????:Hundreds] set [Copy of Total]
--------------------------Get Tens--------------------------
<> Variable Oper: [????:Copy of Total] set ((((whatever))))
<> Variable Oper: [????:100] * [????:Hundreds]
<> Variable Oper: [????:Copy of Total] - [????:100]
<> Variable Oper: [????:Copy of Total] / 10
<> Variable Oper: [????:Tens] set [????:Copy of Total]
-------------------------Get Ones---------------------------
<> Variable Oper: [????:Copy of Total] set ((((whatever))))
<> Variable Oper: [????:10] * [????:Tens]
<> Variable Oper: [????:Copy of Total] - [????:10]
<> Variable Oper: [????:Copy of Total] - [????:100]
<> Variable Oper: [????:Ones] set [????:Copy of Total]
------------------------------------------------------------I Thank you for viewing this tute!
If you want a personal tute please e-mail me at Jiraoxys7@hotmail.com
That's all Folks! :D