ID:150415
 
this is what i put to make me teloport to the town
area
Teleport
var/X = 2
var/Y = 21
var/Z = 2
Enter()
if(usr.Move(locate(X,Y,Z)))
usr << "You have entered the town!"
and it takes me to a town but when i made the same thing but changed the name and the z level it wont let me go on the turf with the area on it and this is the code i have for me other teleport var and here is the code for the telport var


area
Leave
var/X = 2
var/Y = 21
var/Z = 2
Enter()
if(usr.Move(locate(X,Y,Z)))
usr << "You have left the town!"
but it wont let me walk on this leave area and i dont know how to fix it either so if you could help me i would appreciate it alot thanx


~Richter


Richter wrote:
this is what i put to make me teloport to the town
area
Teleport
var/X = 2
var/Y = 21
var/Z = 2
Enter()
if(usr.Move(locate(X,Y,Z)))
usr << "You have entered the town!"
and it takes me to a town but when i made the same thing but changed the name and the z level it wont let me go on the turf with the area on it and this is the code i have for me other teleport var and here is the code for the telport var

Um... it's extremely difficult to understand what you're saying. Run-on sentences are not conducive to getting a point across. Please use some punctuation and a little clarity.

While I can't answer your question without having a clue what it is, I can offer a little advice on the code you already have. I notice you're using usr in a lot of places where you should be using one of the arguments to the function instead. Also, you should consider changing Enter() to Entered(). Specifically, try for something like this:
area/Teleport
var/X = 2
var/Y = 21
var/Z = 2

Entered(atom/movable/M,oldloc)
if(!istype(oldloc,/area/Teleport) && !istype(oldloc,/area/Leave))
if(istype(M,/mob/player))
if(M.Move(locate(X,Y,Z)))
M << "You have entered the town!"

This code won't solve your problem, but it's an improvement. It will work when usr is set to something other than the mob entering the area. The reason I suggest using Entered() instead of Enter() is that Enter() is checked just to see if a user can enter an area, but Entered() handles things after they already have. I threw in the extra check on the old location because if you don't do this, your mob may teleport back and forth forever in an infinite loop depending on how the teleporter is set up; I learned this the hard way during one of my early teleporter experiments.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Richter wrote:
this is what i put to make me teloport to the town
area
Teleport
var/X = 2
var/Y = 21
var/Z = 2
Enter()
if(usr.Move(locate(X,Y,Z)))
usr << "You have entered the town!"
and it takes me to a town but when i made the same thing but changed the name and the z level it wont let me go on the turf with the area on it and this is the code i have for me other teleport var and here is the code for the telport var

Um... it's extremely difficult to understand what you're saying. Run-on sentences are not conducive to getting a point across. Please use some punctuation and a little clarity.

While I can't answer your question without having a clue what it is, I can offer a little advice on the code you already have. I notice you're using usr in a lot of places where you should be using one of the arguments to the function instead. Also, you should consider changing Enter() to Entered(). Specifically, try for something like this:
area/Teleport
> var/X = 2
> var/Y = 21
> var/Z = 2
>
> Entered(atom/movable/M,oldloc)
> if(!istype(oldloc,/area/Teleport) && !istype(oldloc,/area/Leave))
> if(istype(M,/mob/player))
> if(M.Move(locate(X,Y,Z)))
> M << "You have entered the town!"

This code won't solve your problem, but it's an improvement. It will work when usr is set to something other than the mob entering the area. The reason I suggest using Entered() instead of Enter() is that Enter() is checked just to see if a user can enter an area, but Entered() handles things after they already have. I threw in the extra check on the old location because if you don't do this, your mob may teleport back and forth forever in an infinite loop depending on how the teleporter is set up; I learned this the hard way during one of my early teleporter experiments.

Lummox JR


Why are people using these pointlessly long teleport codes?
All you really need is this:

turf/Warp()
icon='Grass.dmi'
Enter(mob/M)
..()
M.loc=locate(x,y,z)
In response to Nadrew
Nadrew wrote:
Why are people using these pointlessly long teleport codes?
All you really need is this:

turf/Warp()
icon='Grass.dmi'
Enter(mob/M)
..()
M.loc=locate(x,y,z)

As I said, Enter() is generally the wrong choice for where to put teleport code. In 90% of games it might work just as well, but there are cases where this could cause very bad things. Remember, Enter() is to check whether you can enter a turf, and Entered() is for after you've actually done so.

Also, overly simplistic code tends to have complex consequences when a game grows bigger. I find it's usually best to include a safety check or two that you're not sure you'll need, then remove them later if you see during debugging that they won't be needed. More often than not, as the game becomes more complex it will tend to expose places where you didn't put in checks, and not having safety checks is a common reason why fixing one bug might mean breaking something else.

Lummox JR
In response to Lummox JR
Though Lummox JR does know what he's talking about, I'll help clarify.

If Enter() never returns 1, then you will never be able to enter that turf using the Move() proc. Entered(), on the other hand, requires no condition.

In other words:
Enter() is a check for permission.
Entered() is what happens once you have permission.