Making Hyperlinks

Posted by Ragnarr on Wed 27 Nov 2002 10:22 PM — 13 posts, 43,715 views.

Australia #0
All I want is a trigger that will make certain output from the MUD [for eg. http://(.*) or (www\..*) ] become active hyperlinks and clickable in exactly the same way as MXP would and as I would when highlighting and selecting "Go to URL" in the drop down menu.

The MUD is actually LambdaMOO and it isn't publeo enhanced but, as it is a MOO, I can program my $player:tell() verb to add the relevant MXP tags. I've experimented with this but the server always sends (i assume) a final \n and escapes my escapes.

E 1024: ( 1991) Secure MXP tag ignored when not in secure mode: <a>

Obviously I am never going to be allowed into Secure Mode and the only way I can send escape sequences is via world.tell() which is never parsed by MXP. Only the server output is parsed... So I've kinda given up on that..

So now, my question/request is, could we please have a trigger option 'Make Hyperlink' (make %1 the url and %2 optional text) or even a Function that my trigger could call, something like, 'world.noteHyperlink(<url>,[optional text])' which would display nice clickable hyperlink and would behave exactly as "Go to URL"? or even just send the output from .tell .note through the MXP parser. I dunno...all I want is nice clickity hyperlinks.

If someone has a workaround, I would be delighted to know about it, if not, i think this would add value to your product. Also, many other smaller mud clients already have this.

Thankyou.
Australia Forum Administrator #1
Added as suggestion #478.
Australia Forum Administrator #2
There is now a Hyperlink script item in version 3.41. You can use that to make hyperlinks that both go to the Internet, or just send commands to MUSHclient.
Australia Forum Administrator #3

Here is an example of it in operation:


Things you can do ... View chat sessions, Visit the forum

Australia Forum Administrator #4
To do the above, I entered this:


world.tell "Things you can do ... "
world.Hyperlink "#chats", "View chat sessions", "", "green","", 0
world.Tell ", "
world.Hyperlink "/world.DoCommand ""Forum""", "Visit the forum", "", "green","", 0
world.Note ""

Greece #5
I do not believe in using the mouse on a MUD.
Yet, i have to say that this function really rocks... Now i can add details on my scripts and make them interface differently and stuff... Great!
Way to go Nick and Ragnarr.
USA #6
I'm trying to set up triggers that will pick up www. and http:// from the world. It's not quite working out. Does anyone have a plugin or a example script in any language that I could look at to figure out what I'm doing wrong. Or maybe just add a toggle to the output configurations to detect them and let the user choose for them to be hyperlinks or not.
Thank You
Norbert
Australia Forum Administrator #7
This example trigger will detect http://xxx and make an additional line with a hyperlink in it.

It can't turn the actual text into a hyperlink because it is world output, not a note, however if you were keen you could omit the original line from output and make a new line with the URL turned into a hyperlink.

You may need to fiddle with the rules for detecting the http://whatever, and to do one that just matched www.something you would need to do it a bit differently - make sure you prepend "http://" to the hyperlink in that case.


<triggers>
  <trigger
   custom_colour="17"
   enabled="y"
   match="http\:\/\/([A-Za-z0-9\.\\\/\?])+"
   regexp="y"
   send_to="12"
   sequence="100"
   other_text_colour="whitesmoke"
   other_back_colour="orangered"
  >
  <send>Hyperlink &quot;%0&quot;, &quot;%0&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, 1</send>
  </trigger>
</triggers>


Greece #8
This would be a nice example of omitting output and then replacing it... Could someone write a small listing that omits the line, and then sends it to the world with the hyperlink? I can't figure out how to do it myself...
Australia Forum Administrator #9
Assuming you only had one hyperlink on a particular line, it would be something like this:


<triggers>
  <trigger
   enabled="y"
   match="(.*)(http\:\/\/(?:[A-Za-z0-9\.\\\/\?])+)(.*)"
   omit_from_output="y"
   regexp="y"
   script="OnHyperlink"
   sequence="100"
  >
  </trigger>
</triggers>


The script needs to go in the script file, or the omit from output also omits the scripted lines. :)


sub OnHyperlink (name, line, wildcards)
  ColourTell RGBColourToName (NormalColour(8)), _
             RGBColourToName (NormalColour(1)), _
             wildcards (1)
  Hyperlink  wildcards (2), wildcards (2), "", "", "", 1
  ColourNote RGBColourToName (NormalColour(8)), _
             RGBColourToName (NormalColour(1)), _
             wildcards (3)
end sub

Amended on Wed 14 May 2003 04:02 AM by Nick Gammon
Greece #10
Oh, I see, so you split it into 3 parts... Great sample, thanks!
By the way, could you clarify the use of the Hyperlink function in a plugin? I.e. if I use it in a plugin, do i have to include its ID, or will the plugin find its ID automatically? That is not mentioned in the online reference.
Australia Forum Administrator #11
You have to put the plugin ID there. Once the hyperlink is in the output window it is not linked to any particular plugin, thus the ID has to be there. The hyperlink function itself does not know what your intentions are.

I have amended the description a bit to give an example of doing that.
Australia #12
I just got the latest Mushclient today and discovered the new hyperlink function. It's FANTASTIC. It works GREAT. This function is much more powerful than I had ever hoped. THANKYOU very much Nick, you are truly a man of the people.