ID:143837
 
This is my code for a Resting verb:
mob
verb
Rest()
if(usr.Rest==0)
usr. << "You begin to rest."
usr.Rest=1
usr.movable = 0
while(usr.HP < usr.MaxHP)
usr.HP += rand(10,20)
sleep(30)
if(usr.HP > usr.MaxHP)
usr.HP=usr.MaxHP
usr << "You stop resting."
usr.Rest=0
usr.movable = 1
return

It works fine except it won't let you stop resting until you have full health and I want it so you'll be able to click rest and stop resting whenever you want in case you get attacked by a monster or whatever.

Right away, I would change all this usr to src, since the src would be you, the player, in this case. Instead of if(usr.Rest==0), using if(!src.Rest) would be a smarter choice. After correcting all that, see if it works.
In response to DarkD3vil666
Well i did what you said but it still doesnt stop resting until they're fully healed.
In response to Monkeykid0049
Isn't that what you'd want them to do? Sit down so they can get fully rested? But if you want, you'd have to code more in order for you to stop when you want. Two ways came to mind:

1. If you move while resting, you stop.
2. If you click Rest again while resting, stop.

Both ways are pretty easy.
In response to DarkD3vil666
Well this is what I came up with:

mob
verb
Rest()
if(src.Rest==0)
src. << "You begin to rest."
src.Rest=1
src.movable = 0
while(src.HP < src.MaxHP)
src.HP += rand(10,20)
sleep(30)
if(src.HP > src.MaxHP)
src.HP=src.MaxHP
src << "You stop resting."
src.Rest=0
src.movable = 1
return
if(src.Rest==1)
src. << "You stop resting."
src.Rest=0
src.movable = 1
return

But it says inconsistent indentations where I have if(usr.Rest==1)
src.movable = 1
return
In response to Monkeykid0049
That just means you messed up somewhere with the tabbing or it's slightly off from the if(!src.Test) up top.
In response to DarkD3vil666
well i fixed two of them but the one where it says
if(src.Rest==1)
it still says inconsistent indentation
In response to Monkeykid0049
actually it says i have 12 errors all on that one line
In response to Monkeykid0049
Monkeykid0049 wrote:
actually it says i have 12 errors all on that one line
okay back to one error on the same line....same error...
In response to Monkeykid0049
This is a forum, you don't have to make post after post. You could just change that with a simple else.
In response to DarkD3vil666
yeah sorry -_-
mob
verb
Rest()
if(!usr.Rest)
usr<<"You begin to rest."
usr.Rest=1
spawn(30) usr.Resting()
else
usr.Rest=0

proc
Resting()
src.movable=0
while(src.HP<src.MaxHP&&src.Rest)
src.HP=max(src.HP+rand(10,20),src.MaxHP)
sleep(30)
src<<"You stop resting."
src.movable=1
In response to Teh Governator
Teh Governator wrote:
> mob
> verb
> Rest()
> if(!usr.Rest)
> usr<<"You begin to rest."
> usr.Rest=1
> spawn(30) usr.Resting()
> else
> usr.Rest=0
>
> proc
> Resting()
> src.movable=0
> while(src.HP<src.MaxHP&&src.Rest)
> src.HP=max(src.HP+rand(10,20),src.MaxHP)
> sleep(30)
> src<<"You stop resting."
> src.movable=1
>

hmm it says inconsistent indentation for 5 of those lines
In response to Monkeykid0049
Monkeykid0049 wrote:
Teh Governator wrote:
> > mob
> > verb
> > Rest()
> > if(!usr.Rest)
> > usr<<"You begin to rest."
> > usr.Rest=1
> > spawn(30) usr.Resting()
> > else
> > usr.Rest=0
> >
> > proc
> > Resting()
> > src.movable=0
> > while(src.HP<src.MaxHP&&src.Rest)
> > src.HP=max(src.HP+rand(10,20),src.MaxHP)
> > sleep(30)
> > src<<"You stop resting."
> > src.movable=1
> >

hmm it says inconsistent indentation for 5 of those lines

That's because, I wrote it in the browser, not in DM.
In response to Teh Governator
yeah but i fixed it so they were properly spaced but it still said inconsistent indentation.
In response to Monkeykid0049
Even if there's the same amount of whitespace, spaces do not equal tabs. Press control-T to show tabs and you'll see.
In response to Garthor
Yeah when I do that it shows >>

mob
verb
Rest()
if(!usr.Rest)
usr<<"You begin to rest."
usr.Rest=1
spawn(30) usr.Resting()
else
usr.Rest=0
proc
Resting()
src.movable=0
while(src.HP<src.MaxHP&&src.Rest)
src.HP=max(src.HP+rand(10,20),src.MaxHP)
sleep(30)
src<<"You stop resting."
src.movable=1

But it still says inconsistent indentation. Even though Ive only got tabs.
heres your problem, your using a resting verb. Resting verbs are boring, do something more fun and have regeneration an automated effect or something.. Resting is old and overdone and boring and pointless.
In response to Masterdan
Masterdan wrote:
heres your problem, your using a resting verb. Resting verbs are boring, do something more fun and have regeneration an automated effect or something.. Resting is old and overdone and boring and pointless.

Yeah, the point of this is to help someone fix their coding problem, not push your own design onto someone else.