• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

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