Hyperlinks to run scripts!

Posted by Ilyena on Mon 05 Apr 2010 12:11 AM — 13 posts, 44,592 views.

#0
I'm trying to display a hyperlink with a script that when clicked will then run a script in the same plug-in. I just can't get it to work.

It keeps sending information to the MUD rather than to the script.
Australia Forum Administrator #1
It can be done as documented here:

Template:function=Hyperlink
Hyperlink

The documentation for the Hyperlink script function is available online. It is also in the MUSHclient help file.



You need the !! notation as explained halfway down that page. If you are already using that can you post exactly what you did? The syntax has to match fairly exactly what is explained there.
#2
I have a function called 'Enque' (supposed to be enqueue, but bad spelling, eh). I wanted to pass in a string to that function as a parameter, but I understand that that would normally be as 'wildcards[1]' since it's normally coming from a trigger.

I have:

Hyperlink ("!!" .. pluginid .. ":Enque(skillName)", skillName, "Click to Add", "red", "black", 0)

at the moment, which sends the following to the MUD when I click on the link:

!!e1c7beb0cc624e2a68010fda:Enque(skillName)

Australia Forum Administrator #3
I tested that and it seemed to work. What version of MUSHclient are you using?
#4
I'm using 4.40. =\
Australia Forum Administrator #5
Can you post a bit more of your script? It worked for me but depending on what was in pluginid and skillName maybe there is a problem there.
#6
--function to color skill list based on percentage, there may be a better way to do this, but I couldn't make a repeat-on-same-line trigger work properly
function Linker(name, line, wildcards)
-- first skill variables
skillName = wildcards[1]
spacing = wildcards[2]
percentage = wildcards[3]
-- second skill variables, if applicable
skillName2 = wildcards[4]
spacing2 = wildcards[5]
percentage2 =wildcards[6]
--third skill variables, if applicable
skillName3 =wildcards[7]
spacing3 =wildcards[8]
percentage3 =wildcards[9]

if (tonumber(percentage) == 0) then --color first skill based on percentage, 0 = red, 1-89 = orange, 90-100 = lime
pluginid = GetPluginID()
Hyperlink ("!!" .. pluginid .. ":Enque(skillName)", skillName, "Click to Add", "red", "black", 0)
-- ColourTell("red","", skillName..spacing..percentage.."%") -- Old code
elseif (tonumber(percentage) > 0) and (tonumber(percentage) < 90) then
ColourTell("orange","", skillName..spacing..percentage.."%")
else
ColourTell("lime","", skillName..spacing..percentage.."%")
end --if


I'm editing someone else's code here, but essentially the purpose is to try to get the 'practice' list from a MUD to show up as coloured hyperlinks, so that you can click on the hyperlink to add the skill to a queue to do something with it.
Amended on Tue 06 Apr 2010 09:22 AM by Ilyena
Australia Forum Administrator #7
I don't get why that doesn't work. It is running in a plugin is it? Not just the main script file?

Can you change the word 'Hyperlink' to 'print' and then run it and show me the exact output? (That will tell us what Hyperlink is doing exactly).
#8
!!e1c7beb0cc624e2a68010fda:Enque(skillName) advanced electronics Click to Add red black 0



Yes. This is in an .xml plugin.
Amended on Wed 07 Apr 2010 12:39 AM by Ilyena
#9
Hi. For some reason it is sending the commands rather than executing them. Is there any reason why it would do that?
Australia Forum Administrator #10
No reason I can think of. I'd have to see the whole plugin to comment further.
#11
Hiya, apologies for digging up an old thread, but I've had a similar problem, and I think I found some extra information..

The problem seems somewhat reproducible, if the hyperlink contains more than 1 word, and the words are on different lines, and you click on the second word (not on first).

For example, I had:
Hyperlink
("!!507b81a882f5015779c84474:Execute("..mobspeedwalk..")", mobspeedwalk, "Execute "..mobspeedwalk.."" ,"green","black",0)
, where among other things mobspeedwalk had a value of
"Run 3s10e7nese;fstar;run 3s2e2ne3s"

Together, with the rest of the plugin, the script outputted to following:
Name: the prince               Area: Faerie Tales II     Roomname: In A Castle     Speedwalk: Run 
3s10e7nese;fstar;run 3s2e2ne3s


If I click on the part after run, (on new line), it will send
!!507b81a882f5015779c84474:Execute(Run 3s10e7nese;fstar;run 3s2e2ne3s).

If i click on the Run, it sends Run 3s10e7nese
fstar
run 3s2e2ne3s

It doesn't have an issue with the blank space, as some shorter values for mobspeedwalk that appear on 1 line can be clicked anywhere.

Hope that helps :)
Australia Forum Administrator #12
Thanks for the detailed report. There was a bug in the way the line wrapped, in that the second line was marked as "MUD output" and not "script note" which caused the test for the "!!whatever" to fail. Fixed in version 4.72.