ID:142089
 
Ok well first off this works:

client
North()
if(usr.controlling) // controlling the object
for(var/obj/movable/O in get_step(usr,usr.dir)) //infront
step(O, NORTH) //move the object North a step instead of you
usr.controlling = 0 // reset controlling so you move again
return // return
else // if controlling has no value
..() // do regular North things
South()
if(usr.controlling)
for(var/obj/movable/O in get_step(usr,usr.dir))
step(O, SOUTH)
usr.controlling = 0
return
else
..()
East()
if(usr.controlling)
for(var/obj/movable/O in get_step(usr,usr.dir))
step(O, EAST)
usr.controlling = 0
return
else
..()
West()
if(usr.controlling)
for(var/obj/movable/O in get_step(usr,usr.dir))
step(O, WEST)
usr.controlling = 0
return
else
..()


By redefining each direction essentially you can control each direction individually and use them for moving the object infront of you each step at a time. But look at this:

client
Move()
if(usr.controlling)
for(var/obj/movable/O in get_step(usr,usr.dir))
step(O,)) // the second argument has to get the user's next direction
usr.controlling = 0
return
else
..() // do regular client/Move() things


Now what I'm trying to figure out is how I could make the second argument of the step proc get the users next movement direction as an argument so the object will move in the users next step direction instead of the user.

If all else fails what I've already done by redefining each movement proc individually will work but I'm just trying to simplify my code if it's possible.

Use Move()'s built in loc and dir args. Also, don't use usr in procs; use src.
In response to Jeff8500
Thanks man. I totally forgot about built in parameters. Yeah you're right I needa get in the habit of using src for usr Kaioken told me the same thing but gotta break the bad habit.
Hmm, what exactly were you doing here? Did you mean the player to be able to just 'push' any obj and mob in front of him? After that object has been moved once it's no longer in the get_step(), so you can't really control it, it's just a one-time push, which if that is what you wanted, can just be implemented by a simple Bump()/Bumped() override or a verb, or something, or if it's not what you wanted, you may want to improve the current behavior.

As for the code, it should be tweaked a little. Instead of having a for()-object looping loop that only loops (excuse the overused usage) for one loop iteration (after the first iteration you're stopping it with 'return' similarly to how 'break' would), use locate() which will give you one item in the Container used (look it up) which you can then just use manually once instead of looping.

Also, try to keep the return values intact when overriding procs with ones. Your first 'return' is somewhat fine as the true player mob indeed didn't move so it reports failure by returning '.' (null), but 0 is slightly more orthodox. And when you're calling ..(), forward its return value back and return it as well (if it's at the end of your code, you can do 'return ..()').
Additionally, 'else' is unneeded under an if() block with a 'return', because if the if() was executed then the proc would have been stopped and not reach your 'else' anyway.