ID:164774
 
mob
player/Move()
if(moveallowed)
var/mob/m=locate(/mob)in usr.target
if(!m)
..()
icon_state="M"
sleep(8)
icon_state="P"
else
step(m,m.dir)
else
return 0

Of course this doesn't work because i'm not changing m's direction before i make it step. How would i do this?
Adam753 wrote:
Of course this doesn't work because i'm not changing m's direction before i make it step. How would i do this?

This is very simple at any case, but you know that you need to change a variable, but you don't know HOW to do it? Thats what you said, and it makes no sense; you should start from scratch with beginner coding tutorials and the DM Guide.
Even that it would still be simple, I assume you forgot to mention you mean to modify 'm.dir' in a specific way which you don't know how to accomplish. If so, state how you want to modify it...
In response to Kaioken
Do you mean you want me to be more specific? Okay. I know what m.dir is and i know how to change it, it's just i don't know what to change it to. Move() could mean any direction, I need to know how to find out which direction the usr pressed!
In response to Adam753
get_dir() is your friend.

get_dir(m,src) would return the direction where src is from where m is standing

get_dir(src,m) would return the direction where m is from where src is standing

.=step(m,m.dir) //Moves m one step ahead
if(.) m.dir = get_dir(m,src) //makes m face src at the new location.. if it was successful.

- GhostAnime
In response to GhostAnime
I belive the Move() proc has a built in variable for direction, well I dont believe I know!
Check out the refrence...
In response to Lyndonarmitage1
It does (the 2nd argument of the Move() proc).. the way Adam presented what he wants confuses me s I replied it with the way that I assumed he was asking.

- GhostAnime
In response to GhostAnime
Hmm, well the get_step idea is closer... I am going to be as specific as i can.

When you Move(), if you have selected a monster, that monster will move instead of you. The problem I am having is that when you use the Move() proc, you can't tell it whether you want it to Move NORTH, SOUTH, EAST or WEST, because you can't record which directional button you pressed which then called Move().

If that doesn't make it clear enough I give up...
In response to Adam753
Well, you can, pretty much.
This is more suited for client/Move() instead. Look it up, and you can check the dir there as well in the same way. You'll know after you look it up.
In response to Kaioken
umm... I don't see what difference it would make using /client instead of /atom but i can't find anything anyway. And the answer isn't get_something() because I need to know the actual direction that was pressed, not just the direction to the usr.
In response to Adam753
You could modify the client/North(), client/South() and so on...

Not sure if thats what your looking for, but when they try and move North then client/North() should be called(Someone correct me if I'm wrong)

-KirbyAllStar
In response to KirbyAllStar
client/Move(Loc,Dir) //Same args are defined for atom/movable/Move().. look it up if you want to know what I mean.

if(Dir&NORTH) world<<"The client _pressed_ a north key (NORTH, NORTHEAST or NORTHWEST"
else if (Dir == EAST) world<<"The client _pressed_ the east key"
.=..()
if(!.)return..() //if, ultimately, it was unable to move
if(Dir == NORTH) world <<"The client moved up north"


- GhostAnime
In response to GhostAnime
GhostAnime wrote:
>    .=..()
> if(!.)return..() //if, ultimately, it was unable to move


(Uhh? Did you mean to call '..()' twice?)
In response to Kaioken
i think
.=..()

Means something, i dont know what, but i'm sure it means something XD
In response to Axerob
Right... tell you what, any 'thing' means 'something'.
Also understand that '.=..()' isn't a special statement or something, which is something people see in it. It's just assigning the value '..()' returns to the '.' var. There're 3 parts, the '.' var, assignation operator ('=') and the (parent) proc call ('..()').Look those up for more info.
And I know what they mean, of course. Thats why I replied to Ghost, because his usage there makes no sense.
In response to GhostAnime
Oh, that's what you meant...
client/Move(Loc,Dir)
for(var/mob/m in usr.target)
step(m,Dir)
return
.=..()

That's all i needed to know all along! =D

Now, go on, explain the problems with my tacky code. I'll guess the first complaints: "usr is evil"? Or "don't end procs with return"? Go on, tell me.
In response to Axerob
Axerob wrote:
i think
.=..()

Means something, i dont know what, but i'm sure it means something XD

. is the default return value for the proc. By default it is null.
mob
Move()
. = ..()
if(.) // successful
mob
Move()
var/drv = ..()
if(drv) // successful

All procs that don't have a return statement return "." which is null unless you modify "." like . += something.