ID:1792530
 
(See the best response by Lummox JR.)
Code:
        RidePet()
set name="Ride Pet"
set category = "Riding"
if(!usr.PetOut)
usr<<"Your pet isn't out!"
return
else
if(!usr.dead)
for(var/mob/pet/P in oview(1))
usr.RidingPet=1
usr<<"You climb onto your [animal]!"
while(usr.RidingPet)
if(usr.dir=="SOUTH")
P.layer=usr.layer+2
else
P.layer=usr.layer-1
P.loc=usr.loc
P.dir=usr.dir
usr.icon_state="riding"
sleep(1)


Problem description:When going south my character will over layer the animal. I want it behind the animal, I tried doing it with a simple if, but that didn't seem to work. Any help would be useful.

Best response
dir is a number, not a string. SOUTH is a constant that equates to 2, but "SOUTH" is a string.

You should also move this dir/layer code to the player's Move() ptoc, because it's not needed any other time. That would allow you to get rid of that polling loop, which is wasteful and not very responsive.