ID:261961
 
In my problem, when I go on stairs, it sends me up one z level. Well, when I try Move()ing there, it doesn't work!
Help would be appreciated.

                if(direction==1)
M.onstairs = 1
var/turf/T = locate(src.x,src.y,src.z+1)
M.Move(T)
M.onstairs = 0
else
M.onstairs = 1
var/turf/T = locate(src.x,src.y,src.z-1)
M.Move(T)
M.onstairs = 0


Thanks in advance,
~~> Dragon Lord
There's no reason you should be using if/else blocks to test for direction; get_step() should handle that. Also, you forgot to check the return value from Move() to see if it was successful.

Better would simply be to use step(), which will do it all in one shot.
if(step(src, dir))
...

Lummox JR
In response to Lummox JR
I don't think you understand what I mean. This piece of coding is in the Entered() procedure in a stair. The direction variable tells it if it is up, or down.

What I'm thinking that you were saying was to change my dir to move liturally up a z level and step that way?

Thanks anyway,
~~> Dragon Lord
Unknown Person wrote:
In my problem, when I go on stairs, it sends me up one z level. Well, when I try Move()ing there, it doesn't work!

Come again? I can't figure out what you are trying to say. It works, but it doesn't work? The Move() function doesn't work, but you are still moving up one z level? Moving up works but you can't move back down? Please be more clear.
In response to Sarkhan
I use Move() and it doesn't go to the location.
In response to Unknown Person
I don't see any major problems, but i am only looking at a portion of the code, and i am forced to assume what the rest of it looks like. For example, i assume that the onstairs variable is there to prevent an infinite loop?

Could you post the entire Entered() proc?
In response to Sarkhan
        Entered(mob/M)
if(ismob(M)&&!M.onstairs)
M.DitheringThing()
var/olock = M.lock
M.lock = 1
M << sound('stairs.wav')
sleep(5)
if(direction==1)
M.onstairs = 1
var/turf/T = locate(src.x,src.y,src.z+1)
M.Move(T)
M.onstairs = 0
else
M.onstairs = 1
var/turf/T = locate(src.x,src.y,src.z-1)
M.Move(T)
M.onstairs = 0
if(src.song)
M << sound(song,1)
sleep(5)
M.lock = olock
if(M.dead)
M.lock = 1
M.DelDither(M)


Here it is..

onstairs is to make sure it when you Move to there, you won't teleport to a loop.

~~> Dragon Lord
In response to Unknown Person
Unknown Person wrote:

Any chance the turf above is dense, or that you overwrote Move()?
In response to Jon88
The turf isn't dense, it is just another copy of the same turf, except it has the opposite number.
In response to Unknown Person
Does the proc work at least once? As in it will let you go up, but not down?

Resonating Light
In response to Unknown Person
There is a variable called dir, which is used for direction. You should probably use that.
In response to Unknown Person
Unknown Person wrote:
I don't think you understand what I mean. This piece of coding is in the Entered() procedure in a stair. The direction variable tells it if it is up, or down.

What I'm thinking that you were saying was to change my dir to move liturally up a z level and step that way?

Actually there is. The built-in UP direction (16) moves you to x,y,z+1, and DOWN to x,y,z-1.

Lummox JR
In response to Lummox JR
OK now I am so frustrated, not that I didn't fix it, because I did. I followed your instructions, but it didn't work. THEN I figured out that Move() automatically is declined because I have my lock on. -_-

Thanks a whole lot,
~~> Dragon Lord
In response to Unknown Person
I'm here to save the day!

client/var/locked = 0

turf/stairs
icon = 'icon.dmi'
icon_state = "whatever"
Entered(mob/M)
if(M.client) //Just added this line cause I thought you might only want players to use the stairs.
if(M.dir == 1)
M.client.locked = 1
M.loc = locate(src.x,src.y,src.z+1)
M.client.locked = 0
if(M.dir == 2)
M.client.locked = 1
M.loc = locate(src.x,src.y,src.z-1)
M.client.locked = 0
else return

client
Move()
if (locked) return 0 //Only overrides move commands from clients
return ..()

Move() only works for leading the mob around a bit, not for entirely relocating it.

Stick whatever else you need in there, I'm too lazy to copy it all.
In response to Enigmaster2002
Uh, first of all, do you bother to read my last thread? I already fixed it.

Second of all, I want to use Move() because moving into new areas are important. That's the key point of it...

[Edit]

Also, that piece of coding would give you runtime errors. What if a free-flying object went into it? You aren't checking if it is a mob, it assumes it is.