ID:146543
 

mob
verb
Rest()
set category = "Commands"
while(chakra<maxchakra)
src << "You are now resting"
chakra++
sleep(1)
if(src.chakra >= src.maxchakra)
src << "You have finished resting"
src.chakra = src.maxchakra
while(Stamina < maxstamina)
Stamina++
sleep(1)
if(src.Stamina >= src.maxstamina)
src << "You have finished resting"
src.Stamina = src.maxchakra


I use it when my stamina is below maxstamina and it does nothing

Try this:
mob
verb
Rest()
set category = "Commands"
while(chakra<maxchakra||stamina<maxstamina)
src << "You are now resting"
chakra++
stamina++
if(chakra>maxchakra)chakra=maxchakra
if(stamina>maxstamina)stamina=maxstamina
sleep(1)
src<<"You finish resting."
In response to Hell Ramen
Hell Ramen wrote:
Try this:
> mob
> verb
> Rest()
> set category = "Commands"
> while(chakra<maxchakra||stamina<maxstamina)
> src << "You are now resting"
> chakra++
> stamina++
> if(chakra>maxchakra)chakra=maxchakra
> if(stamina>maxstamina)stamina=maxstamina
> sleep(1)
> src<<"You finish resting."
>

Yeah it works but when it reaches its max it will stop but when I lower my stamina again it rests without me click the verb.
In response to Broly103
mob
verb
Rest()
set category = "Commands"
while(chakra<maxchakra||stamina<maxstamina)
src << "You are now resting"
chakra++
stamina++
if(chakra>maxchakra)chakra=maxchakra
if(stamina>maxstamina)stamina=maxstamina
if(stamina>=maxstamina && chakra>=maxchakra)break
sleep(1)
src<<"You finish resting."


try that
In response to Zero's Baby
It works but after I rest and I am at full power, then I lower my stamina or chakra again it will say I am at full power when I am not.
I'm not exactly sure what you mean but..:
mob
verb
Rest()
set category = "Commands"
Chakra
if(usr.chakra<=usr.maxchakra - 1)
src << "You are now resting"
chakra++
sleep(1)
if(src.chakra >= src.maxchakra)
src << "You have finished resting"
src.chakra = src.maxchakra
else
if(src.chakra <= src.maxchakra - 1)
goto(Chakra)
Stamina
if(src.Stamina <= src.maxstamina - 1)
Stamina++
sleep(1)
if(src.Stamina >= src.maxstamina)
src << "You have finished resting"
src.Stamina = src.maxchakra
else
if(src.Stamina <= src.maxstamina - 1)
goto(Stamina)

I'm not exactly sure that will work, because I made this in about 2 minutes edited off your own. And i'm in school so, I had to rush, anyway try that and if it doesn't work drop back by and tell me, and i'll be home by then.


~C
In response to Chwgt
Why would you use a<=b-1 when you can use the much more accurate a<b instead?

Lummox JR
In response to Chwgt
Chwgt wrote:
I'm not exactly sure what you mean but..:
> mob
> verb
> Rest()
> set category = "Commands"
> Chakra
> if(usr.chakra<=usr.maxchakra - 1)
> src << "You are now resting"
> chakra++
> sleep(1)
> if(src.chakra >= src.maxchakra)
> src << "You have finished resting"
> src.chakra = src.maxchakra
> else
> if(src.chakra <= src.maxchakra - 1)
> goto(Chakra)
> Stamina
> if(src.Stamina <= src.maxstamina - 1)
> Stamina++
> sleep(1)
> if(src.Stamina >= src.maxstamina)
> src << "You have finished resting"
> src.Stamina = src.maxchakra
> else
> if(src.Stamina <= src.maxstamina - 1)
> goto(Stamina)
>

I'm not exactly sure that will work, because I made this in about 2 minutes edited off your own. And i'm in school so, I had to rush, anyway try that and if it doesn't work drop back by and tell me, and i'll be home by then.


~C
Only porblem it keeps repeating you are now resting.
In response to Chwgt
Chgwt, your version is a whole lot worse than Broly's: Yours uses goto (bad!), while his uses while(), and, as Lummox said, yours has wierd comparisons, while his doesn't.
Broly, you're looking for something like this:

mob/player/verb/Rest()
set category = "Commands"
src << "You start to rest."
while(src.chakra < src.max_chakra || src.stamina < src.max_stamina)
if(src.chakra < src.max_chakra) src.chakra++
if(src.stamina < src.max_stamina) src.stamina++
sleep(1)
src << "You have finished resting."


If you want the player to be able to stop resting before he's been completely rejuvenated, then you want this:

mob/player/verb/Rest()
set category = "Commands"
//toggle src.rest
src.rest = !src.rest
if(!src.rest)
src << "You wake yourself up."
return
src << "You start to rest."
while(src.rest && (src.chakra < src.max_chakra || src.stamina < src.max_stamina))
if(src.chakra < src.max_chakra) src.chakra++
if(src.stamina < src.max_stamina) src.stamina++
sleep(1)
src << "You've finished resting."


Finally, if you want the player not to be able to move while resting, then you want this:

atom/movable
var/allow_movement = 1
Move()
if(src.allow_movement) .=..()

mob/player/verb/Rest()
set category = "Commands"
//toggle src.rest
src.rest = !src.rest
if(!src.rest)
src << "You wake yourself up."
src.allow_movement = 1
return
src.allow_movement = 0
src << "You start to rest."
while(src.rest && (src.chakra < src.max_chakra || src.stamina < src.max_stamina))
if(src.chakra < src.max_chakra) src.chakra++
if(src.stamina < src.max_stamina) src.stamina++
sleep(1)
src << "You've finished resting."
src.allow_movement = 1


If you have any questions, or you're wondering why I did something, then don't hesitate to ask!
In response to Wizkidd0123
I was in school, I didn't really care how it came out, I was in the middle of my C++ class..
In response to Chwgt
Chwgt wrote:
I was in school, I didn't really care how it came out, I was in the middle of my C++ class..

Then you shouldn't have tried to help him! Your code was alot worse than his, and it didn't solve the problem. In fact, you took out everything that he did correctly, and replaced it with something incorrect. Please don't reply to this, as I don't want to hijack Broly's thread.