ID:179019
 
I was reading the guide on how to move players to another world and I got a little confused. I was trying to just move from one world to another by bumping into a boarder but I will also need to move my character through worlds using verbs

I took the code from the guide as I saw it and the only thing I could figure was missing was the locate so I added it to the bottom however when I try to compile I get an error for the verb/goto it says invaled proc name reserved word



mob
Write(savefile/F)
F["icon"] << src.icon
F["name"] << src.name
Read(savefile/F)
F["icon"] >> src.icon
F["name"] >> src.name

Login()
var/savefile/F
F = src.client.Import()
if(F) src.Read(F)

verb/goto(world_name as text)
var/savefile/F = new
src.Write(F)
src.client.Export(F)
src << link(world_name)
src.loc = locate(1,1,1)

now if this was to work by typing in a word and transporting the player I can use it but right now im really just looking for a way to quickly transfer the player by moving to the edge of the map im guessing that this is done by creating an invisible object and transfering the player when they bump into it.

this could be very simple and im over complicating it but please someone help me out or point me in the right direction.</<></<>
There are lots of ways to move the player, but since you want them to move when bumping a border, I suggest this way:
mob/Move(newloc,newdir)
if(isturf(loc))
var/turf/T=get_step(src,newdir)
if(!T && T==newloc) // we're on a border
.... // put in the move code here
return 1
return ..()

The .... section is the trickiest bit; on each border you're going to have to decide which map your player should go to. That's not something I could write up easy example code for, since how you connect maps will vary depending on the game.

I mentioned this Move() method because it makes use of the fact that the borders are solid walls of nothing. By doing this, you don't have to add invisible objects for the player to bump. This may not be the most desirable solution, however, if your game demands a certain look or feel that this method won't provide. It's worth exploring all the options and deciding which works best for you.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
There are lots of ways to move the player, but since you want them to move when bumping a border, I suggest this way:
mob/Move(newloc,newdir)
> if(isturf(loc))
> var/turf/T=get_step(src,newdir)
> if(!T && T==newloc) // we're on a border
> .... // put in the move code here
> return 1
> return ..()



do I need to make a new turf and replace T with its name?
also when you say move code do you mean the location where I want the player to end up?
In response to Treasurecat
Treasurecat wrote:
do I need to make a new turf and replace T with its name?

Nope; you don't need to make any new turfs here. The reason I put in all that code with var/turf/T was this: It first checks the direction the player is walking in, and makes sure that leads to the same turf as newloc. (That is, so if you call Move(locate(upstairs)) this should realize you're not simply walking to the next turf over, and so it won't bother with the border code.)

Actually I should have also included this line right in the beginning:
if(!newdir) return ..()


also when you say move code do you mean the location where I want the player to end up?

What I mean when I say that the .... should be replaced by your own move code is that that's where you decide where and how the player should be teleported. For example, say you're on z-level 1 and you know that z-level 2 is the map to the west of that, and the player happens to be walking west:
if(!loc.Exit(src)) return 0
var/turf/destination=locate(world.maxx,y,2)
if(!destination || !destination.Enter(src)) return 0
loc=destination
return 1 // moved successfully

That moves the player to the right edge of map level 2, as long as nothing is blocking them (ideally, nothing should be). This same code could be used to cross over any border, but the locate() call would change depending on where you wanted the player to go.

Lummox JR
In response to Lummox JR
mob/Move(newloc,newdir)
if(!newdir) return ..()
if(isturf(loc))
var/turf/T=get_step(src,newdir)
if(!T && T==newloc)
if(!loc.Exit(src)) return 0
var/turf/destination=locate(world.maxx,y,2)
if(!destination || !destination.Enter(src)) return 0
loc=destination
return 1
return..()

ok so a couple of error did come up mostly bad vars. where it says (world.maxx,y,z) do I change that to myworld and the corordinates im just trying to figure out what part of the code tells my player where he leaves the map x,y,z, and to what wolrd he gets transported to and what x,y,z

also I think I got the format wrong when I entered this in im a litle scetchy on whether the line under each if needed to be indented I was under the impresion that they did.

thanks for all your help
In response to Treasurecat
ok I think I got it now but im confused on where my guy is ending up I did not get the whole z axis thing how can I control where the player ends up?

mob/Move(newloc,newdir)
if(!newdir) return ..()
if(isturf(loc))
var/turf/T=get_step(src,newdir)
if(!T && T==newloc)
if(!loc.Exit(src)) return 0
var/turf/destination=locate(world.maxx,x,2)
if(!destination || !destination.Enter(src)) return 0
loc=destination
return 1
return..()

my guy keeps ending up in the z 2 axis can someone please help me understand this code.
thanks
The compile error you're getting is simply because you can't name your proc "goto"... That's a name already reserved by the language for a command...so it won't let you use it for something else...

Name it something different and it will compile just fine...

As for how to move a player when he gets to a border...just give the border turf an Entered() proc that contains the moving code...

turf
border
Entered(mob/M)
//code goes here to move the player to the new world
In response to SuperSaiyanGokuX
Something I just thought of that might help you out, though...

When you say transport them to another "world"...do you really mean to another world? Or do you just mean to another map in your game?

The term "world" refers to a whole game itself... So to transport a player to another world via Import and Export means to transfer them out of one game and into another...

You may know this (and I may be insulting your intelligence...lol)... But just in case...I thought I'd clear it up...

If you just mean transport them between different maps...it's a LOT simpler than the methods you've been trying to use...lol
In response to SuperSaiyanGokuX
no I did not know that. I am confused on how moving through other maps work. im not quite grasping the movement code I am trying to figure out what section of the code would control where the player starts to switch maps and where he ends up.
In response to Treasurecat
I was thinking that i dont want the entire border of a world to move the player to another map so bumping an object would probably be the best thing for me wouldnt it?
In response to Treasurecat
The thing to know is that all maps in your game are automatically assigned a z coordinate...

Think of them as being stacked on top of each other... The newest map is always placed at the bottom of the stack (so the first map will be at the top or highest z level)...

You've just got to know which map is at which z level (not something we can help you with)...and when you want a player to move to a different map...just change their z coordinate to match the z coordinate of the map you wish them to go to...

And that can be done in many ways... The most common of which is by a simple line like so:

src.loc = locate(x,y,z)

(Just plug the proper numbers into the x,y,z and that'll take them to wherever you want... So if you want them to go to 1,1 on a map at z level 3, you just put 1,1,3)

That code has to go into a verb or proc owned by the player, though... Like:

mob
verb
Transport(Z as num)
src.loc = locate(1,1,[Z])

That will allow a player to choose a level to jump to and will warp them to 1,1 on that level...

It can get more complicated than that, though...

If you want it to be handled by them walking onto a border...just use the method I described in my first post on this thread...

Give your border turf a proc that warps the player... Like so:

turf
border
icon = 'border.dmi'
Entered(mob/M)
M.loc = locate(1,1,z+1)

Then just place this turf wherever you want the warp tiles to be... When the player steps into those tiles...they will be moved to 1,1 on the very next z level (or whatever you want...that's up to you)...

I know it all sounds very confusing... But as you learn more it'll all start to make more sense...lol
In response to Treasurecat
Well...it would work that way, too...

But you could still use the turf to warp them...just only place the turf on the map in places where you want them to be moved (wherever you'd place the object you're talking about)...
In response to SuperSaiyanGokuX
ok what about this?

turf/shift
Entered(mob/M)
mob/Move(newloc,newdir)
usr.loc = locate(10,10,2

turf/shift
icon = 'shift.dmi
icon_state ="shift1"

I know im doing something wrong because im getting a few errors but I think im starting to grasp the cancept.
In response to SuperSaiyanGokuX
ahh ok I think I have it now thanks
In response to Treasurecat
Treasurecat wrote:
ok what about this?

turf/shift
Entered(mob/M)
mob/Move(newloc,newdir)
usr.loc = locate(10,10,2

turf/shift
icon = 'shift.dmi
icon_state ="shift1"

I know im doing something wrong because im getting a few errors but I think im starting to grasp the cancept.

Just a couple of problems here...

First, you don't need to call the Move() proc at all... Also...since you put the "mob/M" into the Entered() proc...that means that whatever mob enters that tile will be referred to as "M" for the rest of the proc... So you can just drop the "usr" part from the "usr.loc" and change it to "M.loc"... "M" represents "usr" in this case... Lastly...you should put all code that belongs to a certain atom (turf, obj, mob) under one definition of that item... So the "icon = 'shift.dmi' and such can go under the same line that the Entered() stuff goes...

So it should look like this:


turf/shift
icon = 'shift.dmi
icon_state ="shift1"
Entered(mob/M)
M.loc = locate(10,10,2)

And that should work just fine...