ID:259216
 
My current project is going so smoothly it's amazing (knock on wood). Except I have this one block of code that hates me. Yesterday it lured me into posting an erroneous bug report, and today it wants to prevent me from learning a new feature.

The code builds a large string of HTML-formatted text which is stored in a list and shown to the user upon demand. It all works fine -- the text is displayed properly and the links show as links -- but when I click on them, nothing at all happens.

The indentation is correct and the turfs aren't being deleted before the links are clicked... literally nothing happens, except the links change to the "visited" color.

Any help would be appreciated!


Here's my code (read braces as angle brackets):

for(curRow in rows)
for(curCol in cols)
T = locate(curCol, curRow, curDeck)
if(istype(T, /turf/wall/door))
curChar = "{a href=#\ref[T]toggle}D{/a}"
if(T.name == "outer door") curChar = "{a href=#\ref[T]toggle}O{/a}"
else if(T.density) curChar = "*"
else curChar = "nbsp" // ampersand removed for forum display
myMap += curChar

myMap += "{br}"
sleep(1)


door
Topic(myHref)
usr << "entering Topic"
if(myHref == "toggle")
usr << "Consider [name] toggled!"


And, for reference, here's the snippet from the Reference:

mob/verb/test()
usr << "Click {a href=#\ref[src]xxx}here{/a}!"
mob/Topic(href)
if(href == "xxx") usr << "Thank you!"
The code looks okay to me, although without seeing the whole world I can't detect whether something subtle might be interfering. As a base, I tested the following:

mob/Login()
. = ..()
var/turf/T = locate(/turf/door)
usr << "{a href=#\ref[T]toggle}D{/a}"

turf/door
icon = 'door.dmi'
Topic(myHref)
usr << "entering Topic"
if(myHref == "toggle")
usr << "Consider [name] toggled!"

On a map with a door (so that the locate would succeed) and it worked fine.

By any chance are you overloading client/Topic() and forgetting to call ..()? That would prevent the object topics from being called.

Are your object topics ever called?

Hopefully it's something simple, not a bug in the system.



In response to Tom H.
Hopefully it's something simple, not a bug in the system.

Heh... it's something simple, all right!

I cut-n-pasted your code into my bug world and suddenly, before even running it, immediately realized one big difference between it and my own code...

...in my code, the procedure that actually displays the map uses usr << browse(text).

D'OH!

It was so basic it never even occurred to me, which it should have, because I rarely use browse(). (And I wouldn't have thought to use it now, except that I had this vague memory of how some guy... Lenny? Lewis? Llewelyn?... used it to soothe me in a stressful situation... it's all a blur to me now.) I just assumed it would work.

I hurried back to my game and sure enough, that was the problem. Thanks for the help.
In response to Guy T.
On 9/8/00 7:39 pm Guy T. wrote:

I hurried back to my game and sure enough, that was the problem. Thanks for the help.

Good to hear. Incidentally, you can use browse() for these Topic() links. You just have to preface the links with byond://, eg:

{a href=byond://#\ref[T]toggle}D{/a}

Actually, this is the recommended way to make any links, so we should fix the docs.

The reason for the discrepancy is that, by default, text links are assumed to be byond:// links. Browse links are assumed to be http:// links. I would personally prefer that browse links used byond:// by default as well, but it would screw up the viewing of normal web pages, which allow for embedding of #links. It occurs to me now that we could probably detect this more intelligently though and make byond:// the default when the page was generated from within the world. Okay, will do.
In response to Tom H.
Incidentally, you can use browse() for these Topic() links. You just have to preface the links with byond://, eg:

{a href=byond://#\ref[T]toggle}D{/a}

Ah, cool! So I can actually still use the browse() window... that's excellent. Thanks!