Modulus - hpgDesigns/hpgdesigns-dev.io GitHub Wiki
Modulus is an extremely powerful operator that is useful in many common algorithms.
For instance if it is 11:00 and you want to know what hour it will be in 5 hours on a 12 hour clock you can do the following.
show_message("5 hours from 11:00 is " + string((11 + 5) % 12) + ":00"
You may also want to get whether a number is even or odd.
if (number % 2 == 0) {
// even
} else {
// odd
}
It may also be useful to perform some operation every nth iteration of a loop. The following loop will display every 3rd number between 0 and 50.
for (i = 0; i < 50; i++) {
if (i % 3) {
show_message(string(i));
}
}