ID:262625
 
Code:
        PushUp()
if(src.Meditate) return
if(src.Rest) return
if(src.Stamina <= 0) return
if(src.PushUp)
src.icon_state = ""
src.PushUp = 0
src << "<font size = 1>you have finished doing pushups"
return
else
goto STEP1
STEP1
src.icon_state = "pushup"
src.PushUp = 1
goto STEP2
STEP2
var/random= rand(1,12)
if(random == 6)
src << "<font size = 1>Your strength has increased by 1"
src.Strength += 1
if(random == 7)
src << "<font size = 1>Your maximum stamina has increased by 1"
src.MaxStamina += 1
sleep(50)
src.Stamina -= rand(1,2)
src.Exp += rand(1,5)
src.Level()
goto STEP3
STEP3
if(src.Stamina <= 0)
src << "<font size = 1>You are too tired to continue doing pushups"
src.icon_state = ""
src.PushUp = 0
return
else
goto STEP2


Problem description:

When I click the verb Push ups he does his push ups bla bla but when I push it again to make him stop it looks like hes stopped but hes still gaining exp, any ideas?


Dave
Don't use Goto. You can use while() instead.
In response to Kalzar
        PushUp()
if(src.Meditate) return
if(src.Rest) return
if(src.Stamina <= 0) return
if(src.PushUp)
src.icon_state = ""
src.PushUp = 0
src << "<font size = 1>you have finished doing pushups"
return
else
while(STEP1)
STEP1
src.icon_state = "pushup"
src.PushUp = 1
while(STEP2)
STEP2
var/random= rand(1,12)
if(random == 6)
src << "<font size = 1>Your strength has increased by 1"
src.Strength += 1
if(random == 7)
src << "<font size = 1>Your maximum stamina has increased by 1"
src.MaxStamina += 1
sleep(50)
src.Stamina -= rand(1,2)
src.Exp += rand(1,5)
src.Level()
while(STEP3)
STEP3
if(src.Stamina <= 0)
src << "<font size = 1>You are too tired to continue doing pushups"
src.icon_state = ""
src.PushUp = 0
return
else
while(STEP2)


Is that correct? I tookout goto and put while()
In response to Dranzer_Solo
No >.>
In response to Dranzer_Solo
mob/verb/PushUp()
if(usr.Meditate) return
if(usr.Rest) return
if(usr.Stamina<=0) return
if(usr.PushUp) {usr.icon_state="";usr.PushUp=0;usr<<"<font size=1>You have finished doing pushups.</font>";return}
else
usr.STEP1()

mob/proc
STEP1()
if(!src.PushUp)
src.PushUp=1
src.icon_state="pushup"
src.STEP2()
STEP2()
while(src.PushUp)
var/random=rand(1,12)
if(random==6) {src<<"<font size=1>Your strength has increased by 1</font>";src.Strength++}
if(random==7) {src<<"<font size=1>Your maximum stamina has increased by 1</font>";src.MaxStamina++;sleep(50);src.Stamina-=rand(1,2);src.Exp+=rand(1,5);src.Level()}
src.STEP3()
STEP3()
while(src.PushUp)
if(src.Stamina<=0) {src<<"<font size=1>You are too tired to continue doing pushups.</font>";src.icon_state="";src.PushUp=0;return}
else
src.STEP2()

Probably not exactly the best way to put it, but it most likely will work.
In response to Sinoflife
Don't put usr in proc.
In response to Kalzar
Kalzar wrote:
Don't put usr in proc.

Woops, I converted src to usr for STEP1-3(Before deciding to make them procs) and forgot to change back that last line.
And, you're wrong, it's "Usr is invalid in most procs.", or, if you're going for Lummox JR, "No put usr in proc. Ungh."
In response to Sinoflife
Thanks alot it works now and its alot more orginised thanks



Dave