ID:146630
 
Code:
    Meditate()
set category="Train"
if(usr.meditating == 1)
usr.medtime = 5
spawn(50)
usr.medtime = 0
usr.icon_state = ""
usr << "You stop meditating."
usr.meditating = 0
return
if(usr.meditating == 0)
if(usr.medtime == 0)
if(usr.energy > 2)
usr.meditating = 1
usr.icon_state = "meditate"
usr << "You begin to meditate."
spawn(30)
meditation(src)
return
if(usr.energy < 2)
usr.meditating = 0
usr.icon_state = ""
usr << "You need to rest!"
if(usr.medtime == 5)
usr << "You must wait before meditating again."


Problem description:
Everything works except after you stop meditating the stats keep going up anyway. How do I stop this from happening?
Let us see the proc meditation(). I believe you have an infite loop.

-Ryan
In response to Ryne Rekab (#1)
meditation(mob/M as mob)
usr.exp += 1
usr.str += 1
usr.dex += 2
usr.maxpl += 1
usr.energy -= 2
spawn(30)
meditation(src)


its definitely the infinite loop problem. How do I fix that?
In response to JoEn00b (#2)
JoEn00b wrote:
its definitely the infinite loop problem. How do I fix that?

Have some kind of cut off point somewhere.

if(usr.energy < 100>
meditiation(src)

But if it's over or equal, then it will not loop again.
In response to Elation (#3)
It's still doing infinite meditation =/
In response to JoEn00b (#4)
Meh, show us your code again, or better, come in Chatters sometime and use /showtext. Ignore the DBZ bashers there. (like me <_< )
In response to JoEn00b (#2)
Ummm... why do you have an argument for that procedure if you're going to use usr and src in it? That's just baaaaad.

And before LummoxJr does it:

No put usr in proc. Ungh.
In response to JoEn00b (#2)
meditation() //There was no need for that M variable.
do
src.exp += 1
src.str += 1
src.dex += 2
src.maxpl += 1
src.energy -= 2
while(src.energy > 2)
src << "You stop meditating."


There >_> I would comment it out to the max but it's pretty simple to understand.

-Ryan