ID:163701
 
Ok well i need help how would i make a portal that would tele the player onto another map??
Here's what you do.

turf/transporter                              // The turf you step on to transport.
Enter(mob/M,) // Upon entering the spot, any mob is called M
if(ismob(M)) // if the mob steps on the transporter spot...
usr.loc = locate(/turf/transporter) // first step fully onto the transporter
sleep(9) // we'll give u .09 seconds to do that
usr.loc = locate(/turf/heaven) // then teleport to the new spot

Then just make a second turf called 'heaven' and put it somewhere on your other map.
I like the sleep() function because it lets the player get all the way on the transporter before they are wisked away.

Next you'll make a portal to come back from heaven right?
a neat trick to ensure you are not already being beamed back when you first arive is to add this at the bottom...

    step (usr,EAST)    // Gets you off the 2nd portal before you get sent right back.


/bow
This was my first Forum post ever. :-)
In response to Asha_LaPoe
I believe if you use Entered() instead, you can avoid needing to use code to step off the portal.
In response to Rifthaven
In addition, never use usr in implicit procedures (by this, I mean where usr is not clearly defined as the current client calling that certain procedure... only suitable safe-usr usage I know of is in Click()/DblClick(), Stat() and in verbs). Movement procs (Move(), Enter(), Bump(), etc) are implicit procs thus usr is not likely to be the current mob in question (look up usr in the DM Ref... it does NOT mean user).
In response to Rifthaven
Rifthaven wrote:
I believe if you use Entered() instead, you can avoid needing to use code to step off the portal.

Ok good point. For me I use the step feature to help the effect of say... a doorway. Step into the bank and you're warped into the doorway + 1 step inside. That way by backing up you step back onto the portal to go outside. (this is if you utilize your destination turf as a portal when making a return trip)

Thanx for the Entered() note tho, i'll be using it.
In response to GhostAnime
So it would be cleaner and more proper to use M. instead of usr right?
if(ismob(M))
M.loc = locate(/turf/destination)


glad to scoop up pointers such as this. :-)
In response to GhostAnime
Pretty much anything defined under client is usr-safe, too.
In response to Jp
I'm having an issue with locate()
if (M.loc == locate(/turf/portal))


That's fine if your standing on the first /turf/portal Byond finds. But I want it to work if you are standing on any of my portals.

Or rather, I DON'T want the effect to work if you are not on a portal. That's what i'm using this if statement for. (I'm using a clickable link to choose your next destination and the link remains even after you are ported) I tried altering the player's icon state when they are on portals and using...
 if (M.icon_state == "teleporting")
That works in a pinch, but it conflicts with the state of "invisible" i'm using for the effect of ariving.
help plz, and if you do need to see my entire code i'll post it for ya'll. <^>
In response to Asha_LaPoe
Confucious say: Reply to wrong post like talking to wall.

Anyway, as for your problems:

The first one is solved simply by checking the type of your location:

if(istype(m.loc, /turf/portal))
//Standing on a turf that is either /turf/portal or a child of /turf/portal (Say, /turf/portal/blue)


In response to Jp
Splendid! Exactly what I was needing.

Say, do you know how to paralize a player's movement temporarilly? I'll go see if i can find it myself before your reply. :-)

In response to Asha_LaPoe
Tbere's no inbuilt procedure, but you can just override Move():

mob
var/frozen=0

Move()
if(frozen) return 0 //If we're frozen, we can't move
.=..() //Else, do normal Move() stuff and return the normal return value

proc
//Freeze and unfreeze the player's movement, respectively
freeze()
frozen=1

unfreeze()
frozen=0
In response to Jp
Just dandy. I used icon_state to decide when to override movement. Here is the finished effect...
  
// A teleport tube you can only access from the south.
turf/tubes/start
Enter(mob/B)
if(B.dir != NORTH)
sleep()
return ..()
Exit(mob/B)
if(B.dir == SOUTH)
usr.icon_state = ""
if(B.dir != SOUTH)
sleep()
return ..()


// ----------------------------

mob
Move()
if(usr.icon_state == "invisible") return 0
.=..()

// ----------------------------

turf/tubes/start
Entered(atom/movable/A)
sleep(6)
usr << "<FONT COLOR=blue><B>Station Computer: </font></B> Where would you like to transport to? <br> <A HREF=#\ref[src]dockingbay>Docking Bay</A> - <A HREF=#\ref[src]office>Office</A> "

turf/tubes/Frontstart/Topic(Topic)
if(Topic == "office" && istype(usr.loc, /turf/tubes))
usr.icon_state = "invisible" // Here the player becomes invisible and unable to move but the screen view does not change for the next effect.
var/obj/K = new/obj/ghost
var/obj/L = new/obj/ghost
sleep(1)
K.loc = locate(usr.x,usr.y+1,usr.z)
walk(K,NORTH,0) // a 'ghost' light flies upward into the tubes.
sleep(16)
del(K)
usr.loc = locate(/area/Bspot)
L.loc = locate(usr.x,usr.y+16,usr.z)
walk(L,SOUTH,0) // and a second one beams down at the destination spot.
sleep(16)
del(L)
usr.icon_state = "south"


else if(Topic == "dockingbay" && istype(usr.loc, /turf/tubes))
usr.icon_state = "invisible"
var/obj/K = new/obj/ghost
var/obj/L = new/obj/ghost
sleep(1)
K.loc = locate(usr.x,usr.y+1,usr.z)
walk(K,NORTH,0)
sleep(16)
del(K)
usr.loc = locate(/area/Aspot)
L.loc = locate(usr.x,usr.y+16,usr.z)
walk(L,SOUTH,0)
sleep(16)
del(L)
usr.icon_state = "south"

else
usr << "<B><FONT COLOR=red>You are not in a Transport Tube."

It's safe to use usr. in Topic right?
In response to Asha_LaPoe
I'm not sure about the usr-safety of atom/topic(), but you are abusing usr in mob/Move(), turf/tubes/start/Entered() and /turf/tubes/start/Exit().

Movement procedures are quite possibly the unsafest place to use usr. What you should be using is 'src' in Move(), and the argument passed in Entered() and Exit() (Remember to check that the thing passed is actually a mob using ismob() if it's relevant!)

To get an idea of why usr is unsafe in movement procedures, try this code:

turf/fire/Entered()
usr << "Ouch!" //USR ABUSE

mob/verb/push(mob/m in view(1))
m.step(get_dir(src,m))


Then try pushing someone into the fire.
In response to Jp
Jp wrote:
I'm not sure about the usr-safety of atom/topic()

Topic() is usr-safe. usr is the player that clicked the link.

Of course, no proc is safe when it's called manually. But for Topic() you can use the link() proc to call it manually without the potential of making usr unsafe.

-- Data