• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How to detect odd number?

Status
Not open for further replies.
Level 7
Joined
Jul 18, 2009
Messages
272
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.
Top