How to detect odd number?

Status
Not open for further replies.
Use the modulo-function in your condition (under Integer Comparison --> Math - Modulo).

Modulo returns the rest of a division (for example "7 mod 3 = 1").
So "x mod 2" will return 0 for an even number and 1 for an odd number.
 
Try this:
  • Odd or Even
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set Integer = (Integer + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer mod 2) Equal to 0
        • Then - Actions
          • Game - Display to (All players) the text: ((String(Integer)) + = odd)
        • Else - Actions
          • Game - Display to (All players) the text: ((String(Integer)) + = even)
Edit1: AAAAAAAAAAAAAAAA way too late :(

Edit2: Actually meOme, 0 will return for the odd number, not the even one.
 
Status
Not open for further replies.
Back
Top