ID:164000
 
sorry but im new at coding so i need help...

how would i make a resting system i tryed making one but it just went wrong and added 1 hp everytime someone clicked it untill they got full hp, so how would i do it???

also how would i make the stats have hp/maxhp so
stat("health",hp)

but with a / then max hp

thanks for your time :)
stat("Health","[hp]/[maxhp]")


Look up while() for your other problem in the reference.
In response to Zythyr
thank you :)
In response to Bezza010
sorry but i dont understand were to put while() its probly because my rest system is no good i have

mob
verb
rest()
if(usr.hp < usr.mhp)
usr.hp += 1
else
usr<<"your hp is at its max"
return
In response to Bezza010
If you're only going to add 1, you could probably use
usr.hp++

Where ++ means to increment by 1.

For the other part, you would probably want a variable of whether the person is resting or not. So when they click rest, it would toggle the variable and start resting. Also, you want to pause inbetween health increases:
mob/var
resting=0
hp, maxhp

mob/verb/Rest()
resting++ //toggle the resting variable
while(hp<maxhp) //while the player is damaged
hp++ //increase their health
sleep(50) //the 50 there means 5 seconds
resting-- //toggle the variable back

You probably guessed that -- does the opposite of ++: it decreases by 1.

Now you have to let players be able to cancel resting, but I'll let you figure that one out.
In response to Seraphrevan
Seraphrevan wrote:
If you're only going to add 1, you could probably use
> usr.hp++
>

Where ++ means to increment by 1.

For the other part, you would probably want a variable of whether the person is resting or not. So when they click rest, it would toggle the variable and start resting. Also, you want to pause inbetween health increases:
> mob/var
> resting=0
> hp, maxhp
>
> mob/verb/Rest()
> resting++ //toggle the resting variable
> while(hp<maxhp) //while the player is damaged
> hp++ //increase their health
> sleep(50) //the 50 there means 5 seconds
> resting-- //toggle the variable back
>

You probably guessed that -- does the opposite of ++: it decreases by 1.

Now you have to let players be able to cancel resting, but I'll let you figure that one out.

What happened to your ifs that actually makes the toggle work? 0_0
In response to Mecha Destroyer JD
Well I wasn't gonna give him something that was going to work nicely right out-of-the-box. :)
In response to Seraphrevan
thank you i have a working rest system now


btw how would i stop the usr from moving???
In response to Bezza010
You might want to check this post out.
In response to Seraphrevan
thanks again
In response to Mecha Destroyer JD
Mecha Destroyer JD wrote:
Seraphrevan wrote:
If you're only going to add 1, you could probably use
> > usr.hp++
> >


If you're going to use a boolean variable, you should just use the '= operator' to simply set it between true and false. It is much more robust and clean, and more efficient while you're at it.