ID:1878082
 
(See the best response by Lugia319.)
Code:
mob/verb/attack()
stam=-5
world<<src.stam
flick("punch",src)
for(var/mob/enemy/E in get_step(src,src.dir))
var/damage=src.brawn-(E.res/3)
E.hp-=damage
E.numberDisplay(damage)
E.healthCheck()
if(E.intelligence==0)
E.target=src
E.intelligence=1
E.AI()
src.deathCheck(E)




mob/player/verb/Block()
stam=-10
flick("block")





mob/player/verb/Squat()
stam=-5
maxstam=+3
agi=+4
set name = "Squat"
set category = "Excersice"


mob/player/verb/Pushup()
stam=-7
maxstam=+3
brawn=+6
set name="Push-Up"
set category = "Excersice"

mob/player/verb/Situp()
stam=-5
maxstam=+5
maxhp=+3
res=+4
set name="Sit-Up"
set category = "Excersice"

mob/player/verb/Rest()
stam=%10(sleep=5)


Problem description:
code\playerVerbs.dm:29:error: missing left-hand argument to +.
Hello World.dmb - 1 error, 0 warnings

-What exactly am I doing wrong here? To my current knowledge this looks just about right.

-But on a side note. How do I make it so the rest verb regenerates 10% stamina every 5 seconds until its full??

Best response
You've flipped the side of pretty much every equal sign here. For the most part, you won't get syntax errors, but here's the difference.

x =- 10 // x is assigned -10
x -= 10 // x is assigned x - 10


As for your second question, loops.

while(TRUE)
// do stuff
sleep(time)
Thank you. I have fixed it
In response to Lugia319
Infinite loop suspected--switching proc to background.
If it is not an infinite loop, either do 'set background=1' or set world.loop_checks=0.
proc name: Rest (/mob/player/verb/Rest)
usr: the player (/mob/player)
src: the player (/mob/player)
call stack:
the player (/mob/player): Rest()


This is what happens when I try to do it by your loop format. Its not an error but its what shows in the output section when I execute the verb

And when I do it by the set back ground code. I get extremly massive amounts of lag
As the runtime error says, it should be a background proc. You can do this by setting it to background.

mob/verb/LoopWhile()
set background=1 //add line here
while(TRUE)
sleep(time)
In response to Pirion
what do you mean by the
//add line here
after the set back ground code
Add the set background line there. :)
In response to Pirion
 mob/player/verb/Rest()
set background=1
set name="Rest"
set category= "Excersice"
while(TRUE)
stam+=10
hp+=10
sleep(3)


I did this, but Im still having massive amounts of lag
If the while(TRUE) isn't indented - you're running an empty loop with no pause. You need to indent the next lines after the loop.

Additionally, allowing the loop to run multiple times can make that worse - you need logic to stop that (unless that is the intent.

Finally, you are never exiting the loop. You want to exit at some point.

#define clamp(c,l,h) max(l,min(c,h)) //keep within a range

mob
var
tmp/resting = 0
hp = 1
stam = 10
maxhp = 100
maxstam = 100

mob/proc/CanRest()
return !resting

mob/verb/Rest()
//set name="Rest" //reduntant
set category= "Excersice"
set background=1 //low priority

if(!CanRest()) //if can't rest (contain all logic here)
src << "You may not rest."
return

src << "You begin resting."
resting = 1 //stop us from starting multiple times

while(TRUE)//indent the loop stuff
hp = clamp(0,hp+10,maxhp)
stam = clamp(0,stam+(maxstam*0.1),maxstam) //increase by 10%
src << "You start to fell a little better."
sleep(5*10) //every 5 seconds
if(hp >= maxhp && stam >= maxstam)
break //leave the loop if condition is met
src << "You stop resting."
resting = 0//let us rest again
In response to Pirion
Thank you a lot. That has fixed it and it is working flawlessly
Setting background=1 is unnecessary as long as you're sleeping the proc.
On long loops, it prevents the loopcheck from displaying a runtime error, right?
In response to Pirion
It should have that effect, but actually that's what world.loop_checks does. The background=1 setting forces the proc to evaluate, every so many jumps, whether it might be taking too long. If so it calls sleep(0).