ID:151486
 
I'm puzzled as to how I would "countdown" so to speak through odd integers. If I'm not making much sense; I'm trying to count from 3 to any infinite number that's odd. For example:

3 (add odd number
5
7
9
11
13
15
17
19
21
23
25 etc.


What would be the best approach? I'm aware I can use the % operator to determine if the value is an odd number but so far that knowledge hasn't helped me much. I'd appreciate the help!

edit: I realize adding 2 to 1 and adding 2 to 2+1 could create the effect I need, but that's not quite working very well!
What I'm doing here is trying to add to world.maxz and create one type of object in every odd Z level and another type of object ito every EVEN Z level. Hope that clears up any questions.
m not exactly understanding your question very well, do you want a wy to count down using odd numbers or do you...yea
In response to Duelmaster409
uhhhh
proc
IsEven(num)
if(num%2 == 0)
return TRUE
else
return FALSE
In response to Duelmaster409
Duelmaster409 wrote:
What I'm doing here is trying to add to world.maxz and create one type of object in every odd Z level and another type of object ito every EVEN Z level. Hope that clears up any questions.


I would assume that there is a more efficient way to accomplish this, but this is the route I have come up with.

proc/OddCount(maxn)

for(var/n = 0, n <= maxn, n ++)
if(n%2) world << "[n] is ODD"
else world << "[n] is EVEN"

sleep()
In response to RJTaylor
This isn't really what I was asking for. All you're doing is simply creating a for() loop that stops at 25 (which by the way, you don't need to create a variable for). But I can see how this could be applied to my situation with some thought.
Just because a loop increments by 2, doesn't mean you can't use the numbers in between that:

    proc/SpawnThings()
for(var/Z = 3, Z<25, Z+=2)
world.maxz = max(Z+1,world.maxz)
new/mob/Monster(locate(1,1,Z))
new/mob/Treasure(locate(1,1,Z+1))


I'm assuming you want it done all at once, without any delay?
In response to DarkCampainger
No, what I'm doing is creating one at a time. When the object is created it is stored in a list. The list's .len acts as a way to determine which Z level is "selected". This works fine with even numbers but I can't quite get this to work with odd numbers.
I've solved my little question, thanks to everyone who replied. I never knew about the max() proc!