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.
ID:143837
![]() Jun 27 2007, 11:05 am
|
|
![]() Jun 27 2007, 11:20 am
|
|
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.
|
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. |
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 |
That just means you messed up somewhere with the tabbing or it's slightly off from the if(!src.Test) up top.
|
well i fixed two of them but the one where it says
if(src.Rest==1) it still says inconsistent indentation |
Monkeykid0049 wrote:
actually it says i have 12 errors all on that one lineokay back to one error on the same line....same error... |
This is a forum, you don't have to make post after post. You could just change that with a simple else.
|
mob |
Teh Governator wrote:
> mob hmm it says inconsistent indentation for 5 of those lines |
Monkeykid0049 wrote:
Teh Governator wrote: > > mob hmm it says inconsistent indentation for 5 of those lines That's because, I wrote it in the browser, not in DM. |
Even if there's the same amount of whitespace, spaces do not equal tabs. Press control-T to show tabs and you'll see.
|
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.
|
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. |