ID:160800
 
mob
Move()
..()
if(skateboard)
sleep(2)
step(src,dir)


The effect I was hoping for was that when the mob moves, they will continue to move in that direction. But, I can't stop them- every time they move, they gain some speed, so that when they turn round, they're moving twice as fast.
I know why this happens, but I'm not sure how to stop it. So, any ideas?
mob/Move()
while(skateboard)
step(src,dir)
sleep(2)
..()


Try this and report back on what happened :)
In response to Andre-g1
Disaster. Remember that every time he step()s, he Move()s- your code is an infinite loop which calls itself 5 times a second. Not what I want at all!
In response to Adam753
Indeed, that may have slipped me, sorry.

mob/Move()
if(skateboard)
step(src,src.dir)
sleep(2)
else ..()
In response to Andre-g1
he still gains speed. This was the first problem, that he doesn't stop moving even when he hits something, and when you turn round, it moves the other way with twice the speed, because you Move()'d again when you turned round..
In response to Adam753
mob
Move()
if(skateboard)
for()
var/turf/t=locate() in get_step(src,src.dir)
if(t&&t.density) break
step(src,src.dir)
sleep(5)
else ..()


Tested on my environment.
Technically, you could just use the built in walk() (and another call to it later to stop). Anyway, you'd do it like this, no incentive to mess with overriding the Move() proc and accounting for the infinite loops.
mob/var/skating
mob/proc/skate(mdelay=1,dir_override)
src.skating = 1
while(src.skating)
step(src,dir_override? dir_override : src.dir)
sleep(mdelay)

(The 2nd argument is for an option if you want to eg allow skating backwards while still facing forward, etc*)
<small>EDIT: *Although, you'd have to use a manual Move() call with get_step() instead of the shorthand step() proc, since otherwise Move() by default will change the dir anyway</small>

If you wanted to fine-tune turning, you could do it easily, by just modifying the variable it uses to determine the direction, in our case the regular dir var (if there is no dir_override):
client/Move(loc,dir) //called whenever the player sends a movement command
if(src.mob.skating)
src.mob.dir = dir
return 0 //no actual movement will take place from here
return ..() //if he's not skating, just do the usual
In response to Andre-g1
This might be to do with things I've already done with the move proc, but that doesn't work. He doesn't move while he's on the skateboard, and then when you get off the skateboard and move again, he moves with the skateboard effect. And he even moves twice as fast for every time you tried to move while on the skateboard!
I'm going to go clear up my Move() proc now...
In response to Kaioken
I see... But when would I call the skate() proc? Because if you say "From Move()", I'll be so confused :P

Wait, never mind, I got it. Thanks.