ID:160000
 
Ok so umm I made a skill so that i could teleport a certain number of spaces in the direction im facing.. the problem is if im near the edge of a map it brings me to a black zone which i believe to be a vile malicious black hole =)
so is there a way to set boundaries

or

I'm also researching targeting so maybe theres away to select a map to teleport to? or a mob? i don't know i'm 3/4 newb at this so nehelp or push in the right direction besides the DM Guide would be lovely.. seriously please don't be rude and say DM Guide I've read the Whole Thing and got lost half way through it....
If your location is off the map's boundaries, you get sent to 0,0,0 which makes your loc null. Checking for turfs off the map will also return null.
dude i feel your pain i read the dm guide and i didn't understand it about 1/2 to 3/4 way through ... sry i dont know what you are talking about with the problem do you mean to say that you keep teleporting off the map with the teleport verb?
Constraint the teleportation.

Two methods that I can think of are:

1) locate() the turf you want to move first and check if it exists. If not, do not move.

2) use min() with world.maxx and/or world.maxy along with max() with 0 for x/y - so the limit is between 0 and the maximum map size.
This is essentially a Code Problem. Let me distinguish it for you:

How-To: I have an idea or want to do this and this, but I'm not sure how to program or implement it. Or, I want to know how to do something specific with the language. I don't really have any relevant code, because I don't know How To write it yet.

Code Problem: I've programmed something, have some code, but it's either generating some sort of error, works unexpectedly, or messes up in a way.

Since you've programmed in a feature but it's not working as expected and relocates players to invalid locations resulting in them being in 'null' location (essentially a bug), also known as 'void', 'abyss', or 'black hell'. 'off map' is indeed a more accurate definition.

We generally need to see your code to fix the problem, because your code is what's causing it, and there are multiple ways to program things (as well as cause problems), so we can't predict exactly what you've done. However, avoiding this problem will certainly generally amount to confirming the destination location is valid (is a true value) before relocating the player there.
Example:
mob/verb/Simple_Teleport()
var/turf/T = locate(1,1,rand(1,5)) //whatever
if(T) // -- if the destination turf is valid --
src.loc = T

Incidentally, you're probably not using Move() when you should be - I think Move() doesn't allow relocating to null anyway, and does nothing when you try. Since you let players freely teleport themselves, it is important to use the Move() proc to trigger the movement system, otherwise if you've relied on hooks to it such as Entered(), they will not process, which could create bugs or exploits. For example, if you have a lava turf that causes player to immediately get damaged or die when entering it (by use of aforementioned Entered()), if you're setting the loc directly when players are teleporting, they'll be able to use that teleporting to freely travel across your lava ponds unharmed. If you may also have a restricted area by means of overriding the Enter() permissions, such as an admin-only area, players could be able to circumvent that as well in the same way.
In response to GhostAnime
Oh, #2 here is a more useful way of doing it, since it will move you no farther than the edge, and cut the rest off.

I usually don't directly edit an atom's x and y variables, I use Move() instead, or set the loc variable(not much of a difference, but it's faster).
In response to Kaioken
verb
Teleport()
set category = "Skills"
tele = 1
Move()
icon = 'Skills.dmi'
icon_state= "Teleport"
sleep(10)
if(src.dir == NORTH)
src.y = src.y + 5
else if( src.dir == EAST)
src.x = src.x + 5
else if( src.dir == WEST)
src.x = src.x - 5
else if( src.dir == SOUTH)
src.y = src.y - 5
if (src.loc == locate(0,0,0))
usr.loc =locate(1,1,1)
name = "Teleport"
usr<<"Teleport"
tele= 0
Move()

Move()
if(tele == 1)
return
else
..()

//Ok this is my code if ur wandering the Move() proc is to keep the player from moving around while teleport is activated so =) maybe this is a better description. I did put in a snippet of coding that makes it so when the player enters the void by mistake it sends it to start (1,1,1)=/ but when you move closer than 5 spaces to the edge u enter the off map area..so any suggestions?
In response to Xeronin
That's ugly, do you even know how to use move? Look it up.

atom/proc/Get_Turf(dist,dir)
. = loc
if(!.) return
for(dist,dist>0,dist--)
var/turf/T = get_step(.,dir)
if(!T) break
. = T

mob
verb
Teleport()
set category = "Skills"
tele = 1
icon = 'Skills.dmi'
icon_state= "Teleport"
sleep(10)
name = "Teleport"
usr<<"Teleport"
var/turf/T = Get_Turf(5,dir)
if(!T) return
Move(T,dir)
tele = 0

Move()
if(tele) //BOOLEAN LOGIC! Look it up
return
else
return ..() //Edited, you have to return the parent
In response to Jeff8500
This doesn't work you changed the use of move()
move() was meant to freeze the usr from moving around while teleport is in progress now its free to move where ever and
this code wont teleport the player all its doing is changing the icon_state to something different

=/ and yes i copied the code into my code to try it now im lost cuz im to stupid to save my old code =) o well back to the drawing board

Thanks for trying..

Just curious.. did u test this code before posting??
not to insult you or nething
In response to Xeronin
Xeronin wrote:
move() was meant to freeze the usr from moving around while teleport is in progress now its free to move where ever
But calling the Move() proc doesn't stop the user from moving, overriding it and setting your tele var to 1 does. Jeff also does this, so the player still shouldn't be able to move just before teleporting.

this code wont teleport the player
Yes it will, and it does it better as (among other things) it solves your original problem of being able to teleport off of the map.
In response to Nickr5
So far from my testing it hasnt teleported its changed the icon and then it says teleport like its suppose to but no it wont change the location of the chracter it remains stationary unless u move the character
which should not be allowed while teleporting but is....
In response to Xeronin
Copy and paste fail. I put a line in the wrong spot, fix it yourself or don't copy and paste.