ID:262320
 
Code:
mob
verb
Rest()
if(usr.stamina <= usr.maxstamina)
usr << "You sit down and rest"
usr.frozen = 1
sleep(30)
usr.frozen = 0
usr.stamina = usr.maxstamina
usr << "Your fully rested"
if(usr.stamina == usr.maxstamina)
usr << "You don't need to rest"


Problem description:
Ugh......this sux.....but, can you see any errors in this??
even though stamina = max stamina, it rests anyway..... then says "You don't need to rest" right after it..
Scottconley_98 wrote:
Ugh......this sux.....but, can you see any errors in this??
even though stamina = max stamina, it rests anyway..... then says "You don't need to rest" right after it..

Not all that surprising, since you told it to do exactly that. You use the <= operator, which means the first if() will still work as long as the two values are equal. You also used if() for the next block instead of else which would be much more appopriate.

Lummox JR
mob
verb
Rest()
if(usr.stamina <= usr.maxstamina)
usr << "You sit down and rest"
usr.frozen = 1
sleep(30)
usr.frozen = 0
usr.stamina = usr.maxstamina
usr << "Your fully rested"
if(usr.stamina == usr.maxstamina)
usr << "You don't need to rest"

Ya the second if statement... usr.stamina == usr.maxstamina should be usr.stamina >= usr.maxstamina. the way you have it now its only going to tell you that you dont need to rest if your current stamina is equal to your max stamina. the code should looke like this

mob
verb
Rest()
if(usr.stamina <= usr.maxstamina)
usr << "You sit down and rest"
usr.frozen = 1
sleep(30)
usr.frozen = 0
usr.stamina = usr.maxstamina
usr << "Your fully rested"
if(usr.stamina >= usr.maxstamina)
usr << "You don't need to rest"

In response to Odine
It does the exact same thing
In response to Lummox JR
thx lummox! your a god in my country!
In response to Odine
Odine wrote:
Ya the second if statement... usr.stamina == usr.maxstamina should be usr.stamina >= usr.maxstamina.

Actually the second if statement should be an else, not an if statement at all. Also, the first if statement is using the wrong operator.

Lummox JR
In response to Scottconley_98
ya but hes right. using the else statement is easier. i just figured i would keep it at what you were coding through since i didnt know how good or bad you were and i didnt want to confuse you.