# Gw Temp

## Tutorial - 'Variable Digits' by Shadow Blade

An item about RPGMaker 2000 posted on

### Blurb

How to create a "variable digit system", with examples on how to turn 82 into "8" and "2"

### Body

What it does: This system takes a variable and changes it into its digits. That means it

will take a number like 82 and change it into 8 and 2.

What it can be

used for: This is useful for custom systems of all types that use charasets

as numbers.

How to do it:

First set a variable to equal the original one. For the purposes of this tutorial I will

assume that the variable is only meant to be 2 digits long. It is very easy to modify it to

handle larger numbers though.

Set up 9 fork conditions for the variable "Copy Var." Check the "else case" box for all

of them. The first one will check if the number is greater than or equal to 90. The next

fork will check to see if the number is greater than or equal to 80, and it will be inside the

else case of the 90 fork.

Repeat this process until there are forks that go all the way to 10

Now the coding should look like this:

Change Var: Var[0002:Copy Variable] (Set)- Var[0001:Origanal Variable]

If Var (0002: Copy Variable) 90(>=)

:Else Case

If Var (0002: Copy Variable) 80(>=)

:Else Case

If Var (0002: Copy Variable) 70(>=)

:Else Case

If Var (0002: Copy Variable) 60(>=)

:Else Case

If Var (0002: Copy Variable) 50(>=)

:Else Case

If Var (0002: Copy Variable) 40(>=)

:Else Case

If Var (0002: Copy Variable) 30(>=)

:Else Case

If Var (0002: Copy Variable) 20(>=)

:Else Case

If Var (0002: Copy Variable) 10(>=)

:Else Case

End Case

End Case

End Case

End Case

End Case

End Case

End Case

End Case

End Case

Complicated enough? Good! (I have no idea what you just answered.)

What did this do? Right now it does nothing, but it will soon become useful.

Under the 90 fork we will want to change the variable "Tens Digit" to 9. If the original

variable can only have a two digit value and it is more than or equal to 90 the tens value must

be nine. (I'm so smart.)

Next you will want to subtract 90 from the copy variable. This is essential for the ones digit

process to work.

Repeat these steps for all the variables substituting the numbers as necessary.

Now you should have this brilliant bit of programming:

Change Var: Var[0002:Copy Variable] (Set)- Var[0001:Origanal Variable]

If Var (0002: Copy Variable) 90(>=)

Change Var: Var[0003: Tens Digit] (Set)- 9

Change Var: Var[0002:Copy Variable] (-)- 90

:Else Case

If Var (0002: Copy Variable) 80(>=)

Change Var: Var[0003: Tens Digit] (Set)- 8

Change Var: Var[0002:Copy Variable] (-)- 80

:Else Case

If Var (0002: Copy Variable) 70(>=)

Change Var: Var[0003: Tens Digit] (Set)- 7

Change Var: Var[0002:Copy Variable] (-)- 70

:Else Case

If Var (0002: Copy Variable) 60(>=)

Change Var: Var[0003: Tens Digit] (Set)- 6

Change Var: Var[0002:Copy Variable] (-)- 60

:Else Case

If Var (0002: Copy Variable) 50(>=)

Change Var: Var[0003: Tens Digit] (Set)- 5

Change Var: Var[0002:Copy Variable] (-)- 50

:Else Case

If Var (0002: Copy Variable) 40(>=)

Change Var: Var[0003: Tens Digit] (Set)- 4

Change Var: Var[0002:Copy Variable] (-)- 40

:Else Case

If Var (0002: Copy Variable) 30(>=)

Change Var: Var[0003: Tens Digit] (Set)- 3

Change Var: Var[0002:Copy Variable] (-)- 30

:Else Case

If Var (0002: Copy Variable) 20(>=)

Change Var: Var[0003: Tens Digit] (Set)- 2

Change Var: Var[0002:Copy Variable] (-)- 20

:Else Case

If Var (0002: Copy Variable) 10(>=)

Change Var: Var[0003: Tens Digit] (Set)- 1

Change Var: Var[0002:Copy Variable] (-)- 10

:Else Case

Change Var: Var[Tens Digit] (Set)- 0

End Case

End Case

End Case

End Case

End Case

End Case

End Case

End Case

End Case

Notice that under the else case for the ten fork there is a command that changes the tens digit

to zero. If the number is not more than or equal to ten there is nothing in the tens place.

Now, if you have not yet noticed the repetitive nature of this system I suggest that you go read

some "sWitchez for n00bs" tutorial or you should go graduate from preschool.

(Whichever comes first)

The ones digit is very similar to the tens digit so I will not bore you with the details again.

The one thing to notice is that you are now using the variable "Ones digit" in the place of

"Tens digit." The other difference is that you do not have to add in the subtraction commands.

The entire thing will look like this:

Change Var: Var[0002:Copy Variable] (Set)- Var[0001:Origanal Variable]

If Var (0002: Copy Variable) 90(>=)

Change Var: Var[0003: Tens Digit] (Set)- 9

Change Var: Var[0002:Copy Variable] (-)- 90

:Else Case

If Var (0002: Copy Variable) 80(>=)

Change Var: Var[0003: Tens Digit] (Set)- 8

Change Var: Var[0002:Copy Variable] (-)- 80

:Else Case

If Var (0002: Copy Variable) 70(>=)

Change Var: Var[0003: Tens Digit] (Set)- 7

Change Var: Var[0002:Copy Variable] (-)- 70

:Else Case

If Var (0002: Copy Variable) 60(>=)

Change Var: Var[0003: Tens Digit] (Set)- 6

Change Var: Var[0002:Copy Variable] (-)- 60

:Else Case

If Var (0002: Copy Variable) 50(>=)

Change Var: Var[0003: Tens Digit] (Set)- 5

Change Var: Var[0002:Copy Variable] (-)- 50

:Else Case

If Var (0002: Copy Variable) 40(>=)

Change Var: Var[0003: Tens Digit] (Set)- 4

Change Var: Var[0002:Copy Variable] (-)- 40

:Else Case

If Var (0002: Copy Variable) 30(>=)

Change Var: Var[0003: Tens Digit] (Set)- 3

Change Var: Var[0002:Copy Variable] (-)- 30

:Else Case

If Var (0002: Copy Variable) 20(>=)

Change Var: Var[0003: Tens Digit] (Set)- 2

Change Var: Var[0002:Copy Variable] (-)- 20

:Else Case

If Var (0002: Copy Variable) 10(>=)

Change Var: Var[0003: Tens Digit] (Set)- 1

Change Var: Var[0002:Copy Variable] (-)- 10

:Else Case

Change Var: Var[Tens Digit] (Set)- 0

End Case

End Case

End Case

End Case

End Case

End Case

End Case

End Case

End Case

If Var (0002: Copy Variable) 9(=)

Change Var: Var[0003: Ones Digit] (Set)- 9

:Else Case

If Var (0002: Copy Variable) 8(=)

Change Var: Var[0003: Ones Digit] (Set)- 8

:Else Case

If Var (0002: Copy Variable) 7(=)

Change Var: Var[0003: Ones Digit] (Set)- 7

:Else Case

If Var (0002: Copy Variable) 6(=)

Change Var: Var[0003: Ones Digit] (Set)- 6

:Else Case

If Var (0002: Copy Variable) 5(=)

Change Var: Var[0003: Ones Digit] (Set)- 5

:Else Case

If Var (0002: Copy Variable) 4(=)

Change Var: Var[0003: Ones Digit] (Set)- 4

:Else Case

If Var (0002: Copy Variable) 3(=)

Change Var: Var[0003: Ones Digit] (Set)- 3

:Else Case

If Var (0002: Copy Variable) 2(=)

Change Var: Var[0003: Ones Digit] (Set)- 2

:Else Case

If Var (0002: Copy Variable) 1(=)

Change Var: Var[0003:Ones Digit] (Set)- 1

:Else Case

Change Var: Var[Ones Digit] (Set)- 0

End Case

End Case

End Case

End Case

End Case

End Case

End Case

End Case

End Case

I recommend that this coding be placed in a "call" common event.

To modify this to handle larger numbers simply make some coding to handle a hundreds/thousands

digit. You will need to put the new coding ABOVE the tens place coding.

This DOES make a difference.

I hope that this was helpful.