ID:166811
 
wats the var of the direction a mob is facing? i tried using dir but tht just affects the direction in which the client looks at the map, any help?
The last time I checked, a mob's var refers to the direction in which it is facing. Perhaps you were looking at the client's dir instead?

From the DM Reference (which you should have checked before posting!):

under client/var,
This defines the relationship between the world's coordinate system and the player's screen.

under atom/var,
This is the direction that the object is facing.

Next time, hit F1 first :-)
In response to PirateHead
lmao, thx ^^
In response to DarkBelthazor
np lb
In response to PirateHead
how can i code it in, ill give u an example of wat im doing

client/East(atom/A)
if(A.dir == NORTH)
A.turn(NORTH, 90)

but it now says that the dir var = null as a rintime error, any tips?
In response to DarkBelthazor
Yeah, your use of atom/a int he arguments is probably faulty. I don't think that that argument actually exists - and besides, you have the client/mob variable to use, assuming you're wanting to turn the mob. You could easily do

client/East()
if(mob.dir == NORTH) mob.dir = WEST


turn(NORTH,90) will always return WEST, by the way. :-) According to the reference, anyway. I thought it turned clockwise, but what do I know?

If you just want the arrows to turn your mob, you could do

client/Move(loc,dir)
if(loc) ..()
else switch(dir)
if(NORTH) . = step(mob,mob.dir)
if(SOUTH) . = step(mob,turn(mob.dir,180))
if(EAST)
mob.dir = turn(mob.dir,270)
. = 1
if(WEST)
mob.dir = turn(mob.dir,90)
. = 1
else . = 0


Hope that helps a little.

Look up turn(), by the way. It dosn't turn an atom, but rather returns a new direction based on the given dir and the degrees.
In response to PirateHead
i know tht bit bout turn lol, the rest of the code is like EAST, 90 or WEST -90 (i accounted for degree change) but tht other bit is wat i needed, thx ^^
In response to DarkBelthazor
dang! tht bit of code u sent still makes my guy move normally, ill tell ya wat i tried to do ^^, i want to make it so left and right arrows turn the mob round and up arrow sends u in that direction
In response to DarkBelthazor
Yup. I tested and de-glitched it -- and I learned more about how client.Move() works, evidently. This works for me:

client/Move(loc)
var/dir = get_dir(mob,loc)
switch(dir)
if(NORTH) . = step(mob,mob.dir)
if(SOUTH)
. = step(mob,turn(mob.dir,180))
mob.dir = turn(mob.dir,180)
if(EAST)
mob.dir = turn(mob.dir,270)
. = 1
if(WEST)
mob.dir = turn(mob.dir,90)
. = 1
else . = 0


Tell me if it works for you.
In response to PirateHead
YAY, only one thing left now, how do i stop the output to the usr? everytime it turns i get 4 4 4 8 8 1 1 1 8 8 ...etc.
^^ thx
In response to DarkBelthazor
You sargathed it before I could remove the "world << dir" line that I put in there when I was trying to figure out why it was working wierd. Just remove that line. :-)
In response to PirateHead
kk, thx again :), if u ever on Kohaku, Demonic Legends or any other game ive made/coded shout me ^^
In response to PirateHead
plus, i just improved it a little more, so it includes 8 directions without muffing up :)

client/Move(loc)
var/dir = get_dir(mob,loc)
switch(dir)
if(NORTH)
if(mob.in_car == 1)
. = step(mob,mob.dir)
else
..()
if(SOUTH)
if(mob.in_car == 1)
. = step(mob,turn(mob.dir,180))
mob.dir = turn(mob.dir,180)
else
..()
if(EAST)
if(mob.in_car == 1)
if(mob.dir == SOUTHEAST)
mob.dir = SOUTH
else
if(mob.dir == EAST)
mob.dir = SOUTHEAST
else
if(mob.dir == NORTHEAST)
mob.dir = EAST
else
if(mob.dir == NORTH)
mob.dir = NORTHEAST
else
if(mob.dir == NORTHWEST)
mob.dir = NORTH
else
if(mob.dir == WEST)
mob.dir = NORTHWEST
else
if(mob.dir == SOUTHWEST)
mob.dir = WEST
else
if(mob.dir == SOUTH)
mob.dir = SOUTHWEST
else
..()

if(SOUTHEAST)
if(mob.in_car == 1)
mob.dir = turn(mob.dir,225)
. = 1
else
..()
if(NORTHEAST)
if(mob.in_car == 1)
mob.dir = turn(mob.dir,315)
. = 1
else
..()

if(SOUTHWEST)
if(mob.in_car == 1)
mob.dir = turn(mob.dir,135)
. = 1
else
..()

if(NORTHWEST)
if(mob.in_car == 1)
mob.dir = turn(mob.dir,45)
. = 1
else
..()

if(WEST)
if(mob.in_car == 1)
if(mob.dir == SOUTH)
mob.dir = SOUTHEAST
else
if(mob.dir == SOUTHEAST)
mob.dir = EAST
else
if(mob.dir == EAST)
mob.dir = NORTHEAST
else
if(mob.dir == NORTHEAST)
mob.dir = NORTH
else
if(mob.dir == NORTH)
mob.dir = NORTHWEST
else
if(mob.dir == NORTHWEST)
mob.dir = WEST
else
if(mob.dir == WEST)
mob.dir = SOUTHWEST
else
if(mob.dir == SOUTHWEST)
mob.dir = SOUTH

else
..()
else . = 0
In response to DarkBelthazor
Holy crap, you sure did expand it.
In response to PirateHead
PirateHead wrote:
turn(NORTH,90) will always return WEST, by the way. :-) According to the reference, anyway. I thought it turned clockwise, but what do I know?

I thought this was strange at first also, but once I learned circle trig it made more sense. Positive angles moved the terminal side counter-clockwise while negative angles moved it clockwise.

If he wanted to simplify things quite a bit, he could always do:
if(EAST) mob.dir = turn(mob.dir,-45)
if(WEST) mob.dir = turn(mob.dir,45)


You can use negatives ;)
In response to DarkCampainger
Yeah, it does make sense geometrically. It's just my fault that I generally think of things in a clockwise fashion; it's easy enough to settle into the counter-clockwise geometry, especially when a proc works the opposite of what you thought it would.