View Single Post
  #7  
Unread 04-05-2009, 07:04 PM
Drumstix42's Avatar
Drumstix42 Drumstix42 is offline
A Griffon
Featured
 
Join Date: Oct 2004
Server: Antonia Bayle
Posts: 3,287
Default

gm9 is correct. Mathematically the returned value for the mission # can never be greater than 18. The modulus operator is pretty cool and I personally only knew of it's existence in probably the past year or so and never knew a good reason to use it.

I realize now I could probably just use array_size or something, instead of having the hard-coded number 19, but oh well. And yes it allows easily to add/remove missions should it be necessary.

It's simple division, between two numbers, but the % sign uses the remainder, so that the number can never be more than 18.

0%19 = 0 (0 is mission #1 starting at 0 in code)
10%19 = 10
18%19 = 18 (18 is mission #19 since we started at 0 in code)
19%19 = 0 (0 would be the first mission, starting the cycle over)
__________________
"I'm afraid you're guilty of thought-crime. Don't bother getting the door, we'll let ourselves in..."
<Donate to DrumsUI> < [DrumsUI] Updater > < [DrumsUI] Full Interface> < Drumstix42 on Twitch.tv
>
Reply With Quote