How Do Yo Check if a Level is a Multiple of 10?
Blitz3D Forums/Blitz3D Beginners Area/How Do Yo Check if a Level is a Multiple of 10?| 
 | ||
| I'm probably missing some very easy mathematical equation, but, I want to check if the player is on level 10,20,30, and so on. If that happens, a boss will appear, but how do I check if a level is a multiple of 10? | 
| 
 | ||
| IF X MOD 10 = 0 Then X divides by 10 evenly, with no remainder. | 
| 
 | ||
| IT works, thanks! I didn't know about mod | 
| 
 | ||
| the thing I don't like of mod is that it does not work for negative numbers: when I write "-7 mod 10" I expect to get 3, not -7. Anyway its easy to code one's mod. Anyway the syntax is IF X MOD 10 = 0 Then makebossappear(cool, powerfull, supemissiles) | 
| 
 | ||
| Theres anohter potential way, if int(x/10)*10 = x ;Devidable by 10 else ;Not devidable by 10 endif mute point tho, as sswifts provided the answer! :) | 
| 
 | ||
| I am still shakey on MOD squad myself so I would divide the number by 10 and then by itself... if the answer was exactly 1 then viola! you have achieved another level of base 10. RZ | 
| 
 | ||
| MOD just gives you the remainder after dividing by the specified number - if it's 0 then the number divides into the original exactly. just use ABS(X) MOD 10 to avoid probs with negative numbers, but then you shouldn't have a level numbered below 1 anyway I would think. | 
| 
 | ||
| Najdorf:  the thing I don't like of mod is that it does not work for negative numbers: when I write "-7 mod 10" I expect to get 3, not -7.  MOD still gives a zero answer on multiples of -10, i.e., IF X MOD 10 = 0 Then makebossappear(cool, powerfull, supemissiles) will still work at -10, -20, etc, for multiples of 10 | 
| 
 | ||
| Regardless you could use If MOD abs(10) = o then makebossappear(cool, powerfull, supemissiles) abs is absolute value.. makes a neg number a pos and leaves pos as pos. | 
| 
 | ||
| shagwana - better don't use INT this way since it will round floats. Instead use x_floor=floor(x/10)*10 if x - x_floor = 0 ;multiple of 10 else ;Not multiple of 10 endif | 
| 
 | ||
| function qWrap(Quick,low,high) if quick>high then quick=low if quick<low then quick=high return quick end function works for me. if your using whole numbers | 
| 
 | ||
| Neo, What happens when you Qwrap(15,0,10)? You get 0, not 5 :P ABS(X) MOD 10 as Vorderman said.... will do :) |