ID:141109
 
Code:Portal
turf
Entered(mob/M)
.=..()
for(var/obj/door in contents)
M.loc = locate(992,9,1)
del door
if(!M) break


Problem description:this bit of code i had planned to make so that when they walk into/on the door they get teleported, it works. however.. for some reason i do not know, this happens on every object in game, not just the door. how do i make it so that it will only do this on the door, and not all objects ingame?

Narutostory wrote:
Code:Portal
> turf
> Entered(mob/M)
> .=..()
> for(var/obj/door in contents)
> M.loc = locate(992,9,1)
> del door
> if(!M) break
>

Problem description:this bit of code i had planned to make so that when they walk into/on the door they get teleported, it works. however.. for some reason i do not know, this happens on every object in game, not just the door. how do i make it so that it will only do this on the door, and not all objects ingame?


for(var/obj/door/d in contents)

Try that.
In response to Green Lime
turf
Entered(mob/M)
.=..()
for(var/obj/door/d in contents)
M.loc = locate(992,9,1)
del d
if(!M) //BTW, what's the "if not M, break" thing for?
break
In response to Green Lime
worked fine , thank you xD
In response to Narutostory
this is probably the wrong place to do this but i didnt feel like making a new post.

now, seeing as the part above is working, i was planning on adding a feature where you could input a chosen location(x,y,z) for where to go.. either upon entering or creating the door.

turf
Entered(mob/M)
.=..()
for(var/obj/doorout/d in contents)
M.loc = locate(23,2,1)
del d

//how would i go about doing this?

In response to Narutostory
You could prompt the player for the coordinates with the input() proc, though you should probably spawn() it off - otherwise you'll be delaying the total callers of Entered() (and Move()) that time. Example:
turf/choice_portal/Entered(mob/M)
if(ismob(M) && M.client) //make sure M is actually a mob - it could be an obj. since you're prompting for a player choice, you\
should also make sure it's a player

spawn(-1) //prevent callers from needing to wait for the\
player to input the coords

var/x = input(M,"Enter x coordinate:") as num
...
var/T = locate(x,y,z)
if(T) M.Move(T)
else M << "Invalid coordinates!"
In response to Kaioken
this works, however, once i've entered a location, it takes me to the locaton but then continiues to give me the input boxes for the x,y,z variables.. it never stops :P

any idea why this is ?
In response to Narutostory
It seems you've put that under the base /turf type (instead of a specific, single subtype) so it appears whenever you enter any turf.
In response to Kaioken
lol, your right. thanks again xD