ID:1860301
 
(See the best response by Lummox JR.)
Problem description: As what the title suggests, I need some help fully understanding the Topic() proc because I'm a bit lost. And I'm not talking about using it to link() people to url's, or using it to post byond:// addresses. Honestly it looks like gibberish to me even after reading the 9th and 11th chapter of the DM guide and using F1 in DreamMaker to gain some guidance. I downloaded and used the HTML Shopkeeper snippet someone (I forgot his name, sorry) made but I'm just not getting it. Honestly I just need someone to break it down for me kindergarten style. What I need help with is using Topic() to connect words with procs. For example, SS13 using Topic() to allow players and admins to speak with each other. Their names are a hyperlink and when you click a player's name or an admin's privatemessage, a box pops up to message them.

Here's what I don't understand. What's the difference of use between this:
atom/Topic(href,href_list[])

and this?
client/Topic(href,href_list[])


Second, I just don't get the syntax used in this here:
                    html+="<td><a href=byond://?src=\ref[O];action=edit;var=[X]>"


I know I'm not showing the entire code (don't want to cause unnecessary clutter), but it's part of an Edit verb admins have for editing for(var/X) in atom/O on any atom present in the server. I just don't know how one goes about using the Topic() proc to allow a player to click a word and cause another proc to run from it. I don't understand the syntactical connection between them. I couldn't find anything that explain what each component of Topic() (and the arguments inside it) does and how they're used in laymen's terms.

Sorry for the long post.
All links of this format go through client/Topic(), which takes three parameters:

href: the query string for the link, which is to say everything after ?
href_list: same as params2list(href)
hsrc: same as locate(href_list["src"])

By default, client/Topic() will look to see if there was a src parameter. If so, it will try to look up that object by the given reference (or tag). E.g., src=[0x100000c] would refer to a turf; that value is then used for the hsrc argument. If hsrc is found, then client/Topic() will call hsrc.Topic() with all this same information.

In most SS13 code I've seen, client/Topic() does some work on its own, but it will call ..() near the end to fall back on default behavior. That will pass the message along to hsrc.

client/Topic() is a verb, and atom/Topic() is a pseudo-verb, so these are usr-safe. In each, usr should refer to whoever clicked the link.
Hm okay. If it isn't' too much to ask could you use it in an example? Maybe use Topic() to make a person's name clickable to send a message to, or make a word clickable to run a example() proc?

Sorry Lummox it's not clicking. I understand your explanatino of the three parameters of Topic() (at least I think I do), but I don't understand the gibberish in my 3rd example:
                    html+="<td><a href=byond://?src=\ref[O];action=edit;var=[X]>"


I assume 'action=edit' is going to run the Edit() proc (not sure why Edit is lowercased within in that line of code if its going to run the Edit() proc though. And I don't really understand why 'byond://' is behind the '?' and in front of '<\a href='

Lastly, I still don't know what the purpose of putting 'src=' before '=/ref[O]'. I assume '=\ref[O]' means O is the target of the 'action=edit'.

EDIT: the backslash in '<\a href=' was used so the html wouldn't go through and make the lower portion of my post an empty hyperlink.
Best response
action=edit is just one of the params. When href is parsed by params2list(), href_list["action"] will be equal to "edit". This does not mean an Edit() proc is called--not unless whatever Topic() proc handles this decides to call such a proc.

src=\ref[O] will end up as src=[0x100000c] or something similar. So href_list["src"] would be "[0x100000c]". Before client/Topic() is called, it calls locate(href_list["src"]) to look up whatever that object is, and puts that in the third parameter (hsrc) of client/Topic().

If there is an hsrc object, then the default behavior of client/Topic() is to call hsrc.Topic() with the same info.

What's happening in the SS13 source is that there's a client/Topic() handler that does some stuff, calls ..() when it's decided it doesn't want to handle the case, and then the link is handled by some other Topic() proc--like atom/Topic() for instance, or datum/Topic(), depending on what hsrc is. It's that Topic() proc that decides if href_list["action"] being "edit" means anything, and decides what to do with href_list["var"].
Ahhh okay I see, I see! Thanks a lot Lummox.