ID:270832
 
How would I use locate() in Topic()? \ref doesn't seem to work.
var/mob/M = href_list["shopkeeper"]
if(locate(M) in oview(1,src))



Like that?
In response to Justin B
Ops, didn't come out right. What I meant was, using locate() in the <a> part of Topic().
e.g.<br/>
    var/teleportloc = locate(href_list["teleport"])
if(teleportloc) ref.loc = teleportloc

proc/teleport()
world << "<a href=?action=teleportloc&teleportloc=[locate(somewhere)]>click</a>"
// what will locate() be replaced with?

In response to DivineO'peanut
world << "<a href=?action=teleportloc&teleportloc=\ref[locate(somewhere)]>click</a>"
In response to Crashed
That doesn't work.
In response to DivineO'peanut
BUMP(tis me peanut!)
In response to FananaQ
BUMP(tis me peanut!)
In response to DivineO'peanut
You are looking for "teleport" and you have it stored as "teleportloc".
In response to Papoose
Whoops! Well, that was merely a typing mistake, it still occurs when the code is correct.
In response to DivineO'peanut
You need to post more of your code, including the whole Topic() proc, as well as where it is.
In response to Audeuro
Try this. I've tested it, and it works great.

var/list/telepoint_names = list()

obj
telepoint
New()
..()
var/NUMBER = 1
var/NAME = "Telepoint"
while("[NAME]_[NUMBER]" in telepoint_names)
NUMBER += 1
src.name = "[NAME]_[NUMBER]"
telepoint_names += "[NAME]_[NUMBER]"
return

mob

Topic(href,href_list[])
switch(href_list["action"])
if("teleport1")
var/X = text2num(href_list["X"])
var/Y = text2num(href_list["Y"])
var/Z = text2num(href_list["Z"])
if((!X) || (!Y) || (!Z))
usr << "<font color=red>Error: Invalid location.</font>"
return
usr.loc = locate(X,Y,Z)
return
if("teleport2")
var/turf/loc = locate(href_list["loc"])
if((!loc) || (!isloc(loc)))
usr << "<font color=red>Error: Invalid location.</font>"
return
usr.loc = loc
return
..()
return

verb
Teleport_1()
var/list/choices = list()
for(var/obj/telepoint/O in world)
choices += O
var/obj/O = input("Which telepoint?","Teleport") as null|anything in choices
if(!O) return
usr << "Teleport to <a href='?src=\ref[usr];action=teleport1;X=[O.x];Y=[O.y];Z=[O.z]'>[O]</a>."
return

Teleport_2()
var/list/choices = list()
for(var/obj/telepoint/O in world)
choices += O
var/obj/O = input("Which telepoint?","Teleport") as null|anything in choices
if(!O) return
usr << "Teleport to <a href='?src=\ref[usr];action=teleport2;loc=\ref[O.loc]'>[O]</a>."
return
In response to DivineO'peanut
mob
Topic(href,h[])
switch(h["action"])
if("teleport")
var/teleportloc = locate(h["teleportloc"])
if(teleportloc && isloc(teleportloc)) usr.loc = teleportloc

Login()
..()
src << "<a href=?action=teleport&teleportloc=\ref[locate(2,6,1)]>test</a>"
In response to DivineO'peanut
I do believe that your problem is that when a user clicks an URL like that, client/Topic is called as opposed to mob/Topic. To get it to call mob/Topic, you must send the src parameter.

mob
Login()
..()
src << "<a href=?src=\ref[src]&action=teleport&teleportloc=\ref[locate(2,6,1)]>test</a>"