Best title ever.
Anyway, very few people know what Modulo is. (Actually, by now everyone on the forum’ll know it and this won’t be helpful for months)(I’m kidding) so I made this topic to teach them.
I am going to show you a few basic uses for Modulo.
But first, I’m going to say that Modulo is the remainder of a division problem. So for example
10 % 2
Would equal 0. And
5 % 2
Would equal 1.
So now that you know what Modulo is, you will understand how these examples work.
Checking if a number is a multiple of something
If you have a variable which changes, and you need to see if it’s a multiple of something, use this code:
A variation of this can be used - depending on the color - to make a brick wall or a wood panel floor. I’m not going to say how to do this, but it involves subtraction and ‘or’ in check once ifs.
Modulo can be used for a leveling system. For example, if you play Minecraft, it can be used to make a less complex version of that leveling system. (Gary Banner) Just add ways to get experience.
And I could only think of those two examples, but I will add more. In fact, this is on global edit, so add you own examples (in details folders) below the line.
How to check if a number is odd or even
if number % 2 == 0: // the number is even else: // the number is odd
Posted by @MR.GAM3R