ID:139856
 
Code:
mob/proc
Apples()
if(100 > src.apples > 10)
src << "some place 100-10"
return
else
src << "not enough"
return


Problem description:
Now the code above is just made to explain what is bothering me.

I want the proc to check if the apples value of src is between 100 and 10, and if so, do something. Now what happens is that it always outputs "not enough" regardless of the amount of apples, being 20 40 or 90, it does not work.

It's probably staring me in the face but i simply don't get what i'm doing wrong. :)
mob/proc
Apples()
if(src.apples > 10)
src << "some place 100-10"
return
else
src << "not enough"
return
In response to Darker Legends
yes, that's all well and good. but i have more than that one step, and with that logic it will always be TRUE and display the output when i don't want it to.

mob/proc/Apples()
if(src. apples > 10)
src << "blah"
return
if(src.apples > 150)
src << "bleh"
return
//... and so on.

if apples where 153 this would display : "blah","bleh" when i only would want "bleh".

In response to Narutostory
iunno maybe.

mob/proc/AppleGotee()
if(src.apples > 10 && src.apples < 100)
src << "Frogs"
return
else
src << "Dogs go wacko for shmackos"


meh i typed it randomly may not even work lolz.
In response to Midgetbuster
just as i thought xD your version works. I thought you could just type it 100 > src.apples > 10, turns out you can't. but adding && works fine. thanks.
Narutostory wrote:
I want the proc to check if the apples value of src is between 100 and 10

So you want to check two conditions. Instead of using two subsequent if() statements, use the logical AND ( && ) operator to combine the conditions:
if(condition1 && condition2)

// ->

if(number >= 10 && number <= 100) //if number is between 10 and 100 inclusive


DM also has a built-in shorthand syntax for this in if() (which is rather similar to the one it has in switch() cases), so the above can also be written like this:
if(number in 10 to 100) //if number is between 10 and 100 inclusive