Hyperlink_URL2.xml -- Line wrapping error.

Posted by NanbanJim on Tue 27 Jan 2009 10:32 PM — 8 posts, 29,977 views.

#0
Consider: With a standard linewidth of 80 characters and the Plugin "Hyperlink_URL2.xml" enabled. MUSHclient receives:
> think Blah http://testtesttesttesttesttesttesttesttesttesttesttesttesttesttest http://test2test2test2test2test2

MUSHclient notices the single line is too long, makes it 2 lines. You get "Blah http://test" and so on on the first line, and the shorter "http://test2" and so on on the second line. Normal behaviour, and Hyperlink_URL2 doesn't have a problem. However, if the first link itself causes MUSHclient to linewrap/make another line, and if there is another URL on the same wrapped line, such as:

> think Blah blahblah blah blah http://testtesttsttesttesttesttesttesttesttesttesttesttesttesttest blah http://testtesttesttesttest

You get as output:
---Start Output---

Blah blahblah blah blah http://testtesttsttesttesttesttesttesttesttesttesttesttesttesttest
blah Run-time error
Plugin: Hyperlink_URL2 (called from world: A Cleverly Named MUSH)
Function/Sub: OnHyperlink called by trigger
Reason: processing trigger ""
[string "Plugin"]:62: attempt to concatenate field '?' (a nil value)
stack traceback:
[string "Plugin"]:62: in function <[string "Plugin"]:1>
Error context in script:
58 :
59 : for x, y in pairs (newstyle) do -- x is the style number, y is the style-data table.
60 : NoteStyle (y.style)
61 : if y.hypernumber ~= nil then
62*: Hyperlink(hyperlinks[y.hypernumber], y.text, "Go to " .. hyperlinks[y.hypernumber]
63 : , RGBColourToName(y.textcolour), RGBColourToName(y.backcolour), 1)
64 : else
65 : ColourTell (RGBColourToName(y.textcolour), RGBColourToName(y.backcolour), y.text)
66 : end

---End Output---
Or alternately an error box, but that's not so easy to copy-paste. ;) In any event, Hyperlink_URL2 not only ceases to function until you close and re-open that world, but any line that has a URL on it gets replaced with bright red "Trigger function "OnHyperlink" not found or had a previous error."

Suggesting one of:
1.) Change this "replace with bright red error message" behaviour.
2.) Re-load the plugin or scripting engine on error (since sometimes you get this error from the MOTD or other uncontrollable circumstance when you first open a game, but may never encounter the above sort of situation unless you log out and log back in again).
3.) Update Hyperlink_URL2 to not be confused by MUSHclient's line wrapping. (I tried, but couldn't even figure out how to address the issue of "when is a line not a line." Meep.)

Australia Forum Administrator #1
I didn't write that one, and got a bit confused looking at it, but this seems to fix the reported problem ...

In the middle of the plugin, look for these lines:


function OnHyperlink (name, line, wildcards, styles)
 
  hyperlinks = {}
  newstyle = {}
  i = 1
  hyperlinkcount = 0
  doingURL = 0


Change to:


function OnHyperlink (name, line, wildcards, styles)
 
  local hyperlinks = {}
  local newstyle = {}
  local i = 1
  local hyperlinkcount = 0
  local doingURL = 0


It seems the function recurses, I am not sure why. However making its variables local seems to fix the problem.
Australia Forum Administrator #2
The amended plugin is now uploaded to the plugins page.

Oh, and thanks for the detailed error report. That is exactly the sort of stuff we like to see. :)
Amended on Tue 27 Jan 2009 11:10 PM by Nick Gammon
#3
... I'm floored. Wow. 31 minute turnaround? Thank you so much! I didn't even expect it to be looked at for days (I wouldn't have, it's someone else's code)!

I guess that just goes to show, time spent troubleshooting never goes to waste; even if you find yourself at a dead end, someone else may be able to pick up where you left off.

Thanks again!
#4

MUSHclient v4.37


world: "tapestries"
tapestries (dot) fur (dot) com
porttwozerosixnine

issue:
Web URL http: www hypertext links were not "clickable".

resolution:
Installed plugin:
Plugin name: Hyperlink_URL2
id: 520bc4f29806f7af0017985f

ISSUE:
This plug in seems to be making links underlined and clickable. But there is no way to change there color? they are the same color as the test on the line provided.

request:
How do i alter the color of highlighted links with this plug in? Or.. if abandoning this plug in, how do i activate link highlighting with version MUSHclient v4.37??
Australia Forum Administrator #5
This is really a new topic, right?

Edit the plugin file with a text editor. Near the bottom you will find the lines:


 Hyperlink(hyperlinks[y.hypernumber], y.text, "Go to " .. hyperlinks[y.hypernumber]
               , RGBColourToName(y.textcolour), RGBColourToName(y.backcolour), 1)


It deliberately tries to keep the existing colours. To change that, put in the foreground and background colours you want, eg.


 Hyperlink(hyperlinks[y.hypernumber], y.text, "Go to " .. hyperlinks[y.hypernumber]
               , "blue", "black", 1)

#6
Thank you. And yes i appended my seemingly new topic to this older one, because it addresses the same Plug-in, and it's updates, which you made. This keeps the topics together for the sake of congeniality. :}

In short, it seemed relevant. *^-^*


now, furthering my prior question, in hopes of furthering my own understanding of how XML plugins interact with MushClient, I've 3 more questions i would like to ask.

[Q.1]
Would the following also work?
 Hyperlink(hyperlinks[y.hypernumber], y.text, "Go to " .. hyperlinks[y.hypernumber]
               , "#8daaf0", "#000000", 1)


[Q.2]
Would the following work to set the link colors to this worlds "Custom 8" color set?
               , Custom8.textcolour, Custom8.backcolour, 1)


[Q.3]
Can this XML access variables stored in this worlds scripting variables section, to look something like this:
               , ScriptVar.LinkColor.textcolour, ScriptVar.LinkColor.backcolour, 1)




I'm sure my formatting is off, as I'm entirely new to this, and I'm just trying to look at all this logically to get some idea of what's going on inside. But i hope you can follow my 3 questions above, as I'm struggling just to understand my options.

And thank you for your diligent response time.
As well as your contribution to the Mush community.
This is a really nice program, with the options I've been longing for. Thank you, Thank you, Thank you!
~tbe
Australia Forum Administrator #7
Quote:

Would the following also work?

Hyperlink(hyperlinks[y.hypernumber], y.text, "Go to " .. hyperlinks[y.hypernumber]
, "#8daaf0", "#000000", 1)


Yes that will work.

Quote:

Would the following work to set the link colors to this worlds "Custom 8" color set?

, Custom8.textcolour, Custom8.backcolour, 1)


No, but you can use GetCustomColourName and GetCustomColourBackground to get the custom colours:

http://www.gammon.com.au/scripts/doc.php?function=GetCustomColourName

eg.


    , GetCustomColourName (8), GetCustomColourBackground (8), 1)


Quote:

Can this XML access variables stored in this worlds scripting variables section, to look something like this:

, ScriptVar.LinkColor.textcolour, ScriptVar.LinkColor.backcolour, 1)


Not quite like that, but you can access the main world's scripting variables with GetPluginVariable and using an empty string as the plugin ID.

http://www.gammon.com.au/scripts/doc.php?function=GetPluginVariable

eg.


    , GetPluginVariable ("", "textcolour"), GetPluginVariable ("", "backcolour"), 1)