ID:164319
 
I'm trying to make a verb so the player can rest and recover health and so far this is what I have:

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

It seems fine but I want to know how to make it loop.
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
In response to ShadowUser
Since I know someone else is going to point it out, all those usr's should be src's.
In response to LucifersHellion
usr is safe in verbs.
In response to Popisfizzy
Popisfizzy wrote:
usr is safe in verbs.

I used to think so too. I put usr in my communication verbs, then I made a story system for my NPCs to react to players using the existing communication verbs so that NPC and player communication would be consistent. The NPCs started forcing the player who interacted with them to say the NPC's lines. ;p

Player Joe buys some stuff from a shopkeeper NPC.
Joe: Thank you, please come again.

My rule of thumb now is: if you don't have to use usr, don't.