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