ID:916683
 
(See the best response by DarkCampainger.)
Code:
mob
Move(mob/M)
if(ismob(M))
if(M.x >= world.maxx)
M.loc=locate(M.x-world.maxx+2,M.y,M.z)
else if(M.x <= 1)
M.loc=locate(M.x+world.maxx-2,M.y,M.z)

if(M.y >= world.maxy)
M.loc=locate(M.x,M.y-world.maxy+2,M.z)
else if(M.y <= 1)
M.loc=locate(M.x,M.y+world.maxy-2,M.z)

return ..()


Problem description:
Basically i'm trying to make it check if you reach the end of the map it will teleport you to the other side.. so far it doesnt seem to be working at all T.T

any help would be appreciated im not sure what im doing wrong.
still wont work.. that doesnt help lol.
You're using Move() wrong. Check the arguments again: Move()
In response to DarkCampainger
DarkCampainger wrote:
You're using Move() wrong. Check the arguments again: Move()

i see but no matter how i do it

mob
Player
Move()

if(x == world.maxx)
loc=locate(2,y,z)

if(x == 1)
loc=locate((world.maxx - 1),y,z)

if(y == world.maxy)
loc=locate(x,2,z)

if(y == 1)
loc=locate(x,(world.maxy - 1),z)

if(Gravity == 10)
if(MaxPowerLevel < 5000)
if(Class != "Android")
Energy -= 2

if(Gravity == 20)
if(MaxPowerLevel <= 50000)
if(Class != "Android")
Energy -= 4

if(Gravity == 30)
if(MaxPowerLevel <= 100000)
if(Class != "Android")
Energy -= 6

if(Gravity == 40)
if(MaxPowerLevel <= 150000)
if(Class != "Android")
Energy -= 8

if(Gravity == 50)
if(MaxPowerLevel <= 200000)
if(Class != "Android")
Energy -= 10

if(traveling || movingeast || movingwest || movingsouth || movingnorth || movingnortheast || movingnorthwest || movingsouthwest || movingsoutheast || movingtotarget)
if(traveling)
new/obj/Misc/PodTrail(loc)
else if(ssj || ssj2 || ssj3)
new/obj/Misc/SSJTrail(loc)
else if(MaxPowerLevel >= 800000 && NamekFusions >= 1)
new/obj/Misc/SuperNamekTrail(loc)
else if(spiritBursting)
new/obj/Misc/SpiritBurstTrail(loc)
else if(KaiokenLevel > 0)
new/obj/Misc/KaiokenTrail(loc)
else if(Oozaru)
new/obj/Misc/OozaruTrail(loc)
else
new/obj/Misc/NormalTrail(loc)

..()


it still wont move me.

i use the step proc for movement and move_towards
Best response
What you'll want to do is inspect the default Move() arguments (NewLoc and Dir specifically) and see if they're moving off the edge. If they are, NewLoc will be null, their pre-movement x and/or y coordinate will be on the edge of the map, and the movement Dir will be point off the edge. If that happens, you want to change NewLoc to a new wrapped-around coordinate, and then pass it to the default action. Here's some of it to get you started:
mob
Player
Move(NewLoc, Dir)
if(/* Check if moving off edge */)
NewLoc = locate(/* Wrapped coords */)
return ..(NewLoc, Dir)
I see thanks.

You're a great help Dark.
Seems a little silly to check this on every step. Especially when 99% of the steps probably wont involve the edges. Why not make four turf types, one for each side of the map, line the edges of the map with them, and "teleport" the player when they step on it?
In response to Aaiko
Well, depending on how you set it up, you might end up with a ring of two tiles around your map that no one can step on. Then you would have to account for that in your map output to hide the seams, and all other custom processes like view(), get_dist(), ect to ignore those edge tiles.

I wonder if Exit() is called when trying to move off the map. If it is then you could do that seamlessly.

<edit>
Oh, also, it's worth noting that this question is part of a larger problem of creating a visually seamless map. That might not have been evident from the original post.
In response to Aaiko
Eight turf types if you allow for diagonal movement.

I do this myself, it's good for not only looping the map but also for bleeding maps into eachother; you can send someone into a different locations on 'down the road'.

Then you don't have to check if they're at the edge of the map, you only have to take actions uppon sending them to the other side.
In response to DarkCampainger
DarkCampainger wrote:
Well, depending on how you set it up, you might end up with a ring of two tiles around your map that no one can step on. Then you would have to account for that in your map output to hide the seams, and all other custom processes like view(), get_dist(), ect to ignore those edge tiles.

I wonder if Exit() is called when trying to move off the map. If it is then you could do that seamlessly.

I wonder the same thing..gonna test.
This recent request ask for what this person is having issues with. Someone replied with a link to a libary that does this. It works wounderfuly. It uses a 'map edge' turf for each cardinal direction.

This is an excellent example to go off of.