# Complex Event Help: Number Reduction

#### Pubicbear

##### Warper
Hey guys, This is a somewhat odd request but I'm in a little over my head here considering I'm only used to basic eventing but just wondered if it'd be possible to do a reduction of 8 digits but with some special exceptions.

For example:

Players birthdate is (05/07/1988) so he inputs the following (05071988)

I would then like it to reduce these numbers in the following way.

Calculation 1: 0 + 5 + 0 + 7 + 1 + 9 + 8 + 8 = 38

Calculation 2: 3+8=11

Calculation 3: 1+1=2

If the final total of Calculation 1 = 11, 22, 33, or 44 (No further reduction needed but if it doesn’t equal one of those numbers I’d like it to continue reducing to a single digit)

Would It then be possible to turn on a switch that correlates with each final reduction?

Like if the number is reduced to 1, turn on a switch named 1.

If the number is reduced to 2, turn on switch named 2.

But if the number is reduced to 11,22,33 or 44 in Calculation 1, turn on switch named 33.
etc.

Last edited:

#### Kes

##### Veteran
I strongly suggest that you look at Andar's compilation of info for new users. Among the many excellent things there are links to 2 playable tutorials, one on Event Commands and the other on Switches and Variables. You absolutely need a firm grasp of these if you are going to make a game, and for the particular query you have now.

#### Andar

##### Veteran
basically this can be done in two different ways:
Either with scripting knowledge and string conversion commands to seperate the different numbers.
Or by control variable with the modulo operation to do the same.

If you don't know how to program (probably or you wouldn't ask this), then the modulo operation is vital for this - check your advanced math schoolbooks on it. It is rarely used in regular live, but it is the third type of the second class operations (multiplication, division and modulo) and it is very usefull in programming, especially game programming.

#### Aloe Guvner

##### Walrus
OK so it can be done without any scripting (though scripting may be easier):

[when I say V1, I mean variable #1]
• The player inputs 05071988 into V1
• Set V2 as (V1 % 10)
• % is the "modulus operator" sometimes abbreviated as mod
• Set V3 as (V1 % 100)
• Set V4 as (V1 % 1000)
• Set V5 as (V1 % 10000)
• ... Continue until you did all 8 digits...
Test play and press F9 to see the variable values. Hopefully you can understand what the % did. But you're not done yet.

Back to the event and add more commands, this time working backwards:
• Set V9 as (V9 - V8) / 10000000
• Set V8 as (V8 - V7) / 1000000
• Set V7 as (V7 - V6) / 100000
• Set V6 as (V6 - V5) / 10000
• ...keep going until you get all the digits
Now test play again and press F9. All the variables should be correct now, and you can add them together for the rest of your scenario.

### Latest Profile Posts

If you're a RM plugin developer, and you're reading this...

Thank you. You're awesome. Even if I haven't used your plugin, your work is appreciated.
tomorrow is the finale of my Endurance

What a fun tileset I've got here so far!
Minecraft Tiles, Maid Day, Custom Menu, Retry at GameOver, Save in Appdata | RPG Maker News #36