Today you will learn how to split variables using the MOD feature. Variable splitting divides a variable's digits into variables of their own. This is very useful for CMS's and CBS/ABS's.
Example: If I were to MOD the number 1111, I could break that number into 4 variables, each equal to 1. This is very useful for displaying numbers without overloading with fork conditions.
What the MOD feature does is divide the number, but discards everything except for the remainder. The remainder is the value stored into a separate variable.
Example: If I mod 1234 by 10, the result would be 4. 1234 divided by 10 is 123.4, right? So the ending result would be the remainder, and the rest of the number is discarded.
Splitting the number from the ONES digit:
Simply take your number and MOD it by 10. Example: The number 436,426 MOD by 10 will produce 6.
Splitting the number from the TENS digit:
MOD your number by 100, then divide by ten. Example: The number 1,234 divided by 100 equals 12.34 which produces a MOD value of 34 (the remainder is all that is being used). When you divide by 34 by 10 you really get 3.4, but RM2K3 throws away any remainder when you regularly divide. The only way to obtain a remainder is through MOD. The end result is the value 3.
Splitting the number from the HUNDREDS digit:
MOD your number by 1000, then divide by 100. Example: 1234 MOD 100 divides the number into 1.234. Since we used MOD, the resulting value is 234. Divide by 100 and 2 is your result.
Splitting the number from the THOUSANDS digit:
Mod your number by 10,000 then divide by 1000. Example: this the bnumber1234 into this form .1234, producing the MOD number 1234, which is divided by 1000 to extract 1.
Now all you need to do is create 4 other digits corresponding to their respective digits:
Example code from my game's ABS:
I put mine into fork branches, so that if the number didn't exceed 1000, it wouldn't try to MOD for the THOUSANDS place. Then set the variable I was MODing equal to my digit variables, that way I could extract each digit from the separate variables.
Branch if VAR [001 DAMAGE] is 1000 or more
<> Variable Oper: [002 Damage 1000s] Set, Var [001]'s Value
<> Variable Oper: [003 Damage 100s] Set, Var [001]'s Value
<> Variable Oper: [004 Damage 10s] Set, Var [001]'s Value
<> Variable Oper: [005 Damage 1s] Set, Var [001]'s Value
<>
Else Handler
Branch if VAR [001 DAMAGE] is 100 or more
<> Variable Oper: [003 Damage 100s] Set, Var [001]'s Value
<> Variable Oper: [004 Damage 10s] Set, Var [001]'s Value
<> Variable Oper: [005 Damage 1s] Set, Var [001]'s Value
<>
Else Handler
Branch if VAR [001 DAMAGE] is 10 or more
<> Variable Oper: [004 Damage 10s] Set, Var [001]'s Value
<> Variable Oper: [005 Damage 1s] Set, Var [001]'s Value
<>
Else Handler
Branch if VAR [001 DAMAGE] is 9 or less
<> Variable Oper: [005 Damage 1s] Set, Var [001]'s Value
<>
End
<>
End
<>
End
<>
End
Variable Oper [005 Damage 1s] Mod, 10
Variable Oper [004 Damage 10s] Mod, 100
Variable Oper [004 Damage 10s] / , 10
Variable Oper [003 Damage 100s] Mod, 1000
Variable Oper [003 Damage 100s] / , 100
Variable Oper [002 Damage 1000s] Mod, 10000
Variable Oper [002 Damage 1000s] / , 1000
Variable Oper [001 DAMAGE] Set, 0
After that you create an event in your COMMON EVENTS that shows the corresponding pictures. A different tutorial on that will be later. It will focus on showing the damage numbers in relation to where the MONSTER is located on the screen.
Hope this helps!