ID:144863
 
Code:
var/impulsing=0

mob/verb
Impulse(mob/M)
if(istype(M,/mob)) //Make sure it's a mob
impulsing=1
step(M,M.dir)
..()


Problem description:

So...I want to make a verb that when you press it, you continually travel in one direction. I know what I did there was wrong, but yeah. That's what I have.

mob
var/impulse_on = FALSE
verb/impulse()
impulse_on = !impulse_on
proc/impulse()
if(impulse_on)
step(src,src.dir)
sleep(1)
New()
..()
impulse()
client
Move()
if(mob.impulse_on) return FALSE
else return ..()


Something like that?
In response to PirateHead
It doesn't work for some reason...
In response to GohanIdz
instead of proc/impulse, do proc/do_impulse()

And in New(), instead of calling impulse(), call do_impulse().

It's a conflict between the name of the proc and verb that I created. Oops.
In response to PirateHead
mob
var/impulse_on = FALSE
verb/impulse()
impulse_on = !impulse_on
proc/do_impulse()
if(impulse_on)
step(src,src.dir)
sleep(1)
New()
..()
do_impulse()
client
Move()
if(mob.impulse_on) return FALSE
else return ..()




Still doesn't work.
In response to GohanIdz
I bet my toe NPCs do move and you don't. You're blocking out the client/Move(). When pulsing, it returns null, zero, nada, FALSE. So you can't use step(), plainly because it uses Move().
In response to Mysame
So how would I fix it x_x
In response to GohanIdz
Anyone at all know >.<
In response to Mysame
Mysame wrote:
I bet my toe NPCs do move and you don't. You're blocking out the client/Move(). When pulsing, it returns null, zero, nada, FALSE. So you can't use step(), plainly because it uses Move().

Mysame, returning a null value in client/Move() will NOT block moves off of mob/Move(). client/Move() calls mob/Move(). Returning a null value in client/Move() will not stop moves called directly in mob/Move(), such as step(). Returning null in client/Move() is used to disable the player from controlling their mob.

The problem is that step() will only, you guess it, step once. You can use walk(), then call walk(target, 0) when you want the player to stop. You'll also have to remember to disable client/Center(), since by default, it calls walk(src.mob, 0), which stops the walking.

mob
var/impulse = 0
verb
impulse()
src.impulse = !impulse
src.do_impulse()
proc
do_impulse()
if(src.impulse)
walk(src, src.dir, 1)
else
walk(src, 0) // stop the walking if the impulse is gone

client
Move()
if(src.mob.impulse) return 0
return ..()


~~> Unknown Person