ID:150157
 
I've tried several different ways and none of them worked. Can someone tell me how to change a mob's z level?
src.loc=locate(x,y,z)
usr.move(locate(1,1,z) //z being new z level

(don't use different maps. Using different maps is bad!)

unimatrix
In response to Nadrew
I tried:
Entered(atom/M)
if(ismob(M))
var/n = M.z - 1
usr.loc = locate(M.x, M.y, n)

But, when I compile, I get the following error: "M.loc:cannot change constant value" Maybe it's a bug? (I'm using 307b10)
In response to Evilkevkev
Nope, not a bug. try

M.loc=locate(M.x,M.y,M.z-1)
In response to Nadrew
i had tried that too... same problem
and also I tried (M.z-1) all with the same result.
In response to Evilkevkev
Evilkevkev wrote:
I tried:
Entered(atom/M)
if(ismob(M))
var/n = M.z - 1
usr.loc = locate(M.x, M.y, n)

But, when I compile, I get the following error: "M.loc:cannot change constant value" Maybe it's a bug? (I'm using 307b10)

I think your problem is that you're using usr instead of M. The usr value is probably defined as an ordinary atom, not an atom/movable. You can also changed atom/M to atom/movable/M, so DM will know that changing M.loc is legal.

Lummox JR
In response to Evilkevkev
Why dont you try
turf
grass
icon = 'grass.dmi'//you need the grass icon
Enter()
usr.loc=locate(x,y,z)
or even better use tags instead of locations
In response to Greg
or even better use tags instead of locations

Not for my purposes, I just need it to move to a different z level because the layout of the area is exactly the same and all the changes is the z level.

I can't just say "go to z level 5" because there are are three levels all with this same stairs turf and stairs on z level 3 would send you to 5 as well as z level 1 and 2 and 4.

I got it figured out, though. Thanks anyway.
In response to unimatrix
unimatrix wrote:
(don't use different maps. Using different maps is bad!)

There is absolutely nothing wrong with using separate map files. You just have to keep track of which level is which, either manually or within the code. You also need to remember that the maps will expand to the size of the largest file included.

I find using separate map files very useful. If I wish to change a level, it's much easier to find if the files are separate, and you can add or remove levels simply by toggling a checkmark. If I want one dungeon level in the debug version but a different one if it is the final release version, it's much easier to use a single level in each map file and select the right one for the current task.

Using different maps is fine. Predisposing newcomers against something you don't understand clearly is bad.
In response to Evilkevkev
Evilkevkev wrote:
i had tried that too... same problem
and also I tried (M.z-1) all with the same result.

This should be your final code:
Entered(atom/moveable/M)
if(ismob(M))
var/n = M.z - 1
M.loc = locate(M.x, M.y, n)

or you could simplify further:
Entered(mob/M)
M.loc = locate(M.x, M.y, M.z-1)