Hyperlinked IH

by Unknown

Back to Mechanic's Corner.

Unknown2005-11-15 14:25:26
MUSHCLIENT

Something I came up with while ratting. This will replace the normal IH text with hyperlinks bound to a targetting alias ("tn *" in my case, edit the script function at the Hyperlink line to change to whatever you use), so you can target anything in a room by clicking on it. C/p into an empty text file, save to your plugins directory, and install under File->Plugins:

CODE





  name="HyperlinkIH"
  author="Avator"
  id="254643e1ec72b967451e1d3e"
  language="Lua"
  purpose="Targetting by clicking on lines in IH output"
  save_state="y"
  date_written="2005-11-15"
  requires="3.65"
  version="1.0"
  >

   
The first argument ("tn " .. wildcs) is the text that should match the alias. If your targetting alias is "t *" then replace that argument with "t " .. wildcs.


]]>








    enabled="y"
  match="^\\"((?:+ )*?)(+\\d+)\\"(\\s+)(.*)$"
  name="ih_trigger"
  omit_from_output="y"
  regexp="y"
  script="IHReplace"
  sequence="100"
 >
 











    script="OnHelp"
  match="HyperlinkIH:help"
  enabled="y"
 >
 






Sekreh2005-11-16 01:43:40
So totally imported. Thanks!
Unknown2005-11-16 02:00:45
I am going to have to try this when I get home!

EDIT: hmm I wonder how this will pair up with Ethelon's system of setting a target.
Unknown2005-11-16 02:38:11
Just change it so rather than having it set a variable in this script, it runs the alias "x (newtarget)", setting his system's target to whatever you clicked.
Unknown2005-11-16 03:04:29
It's fine I think, I realised there was a space in the script to put in the alias for targetting. I am not sure what the wildcards are for though?
Unknown2005-11-16 04:38:01
The only wildcard you are interested in is the second one, since that's the one that contains what is targetted. They go like this:

CODE

| %1  |  %2   |        %3          |
"baby rat1234"       a baby rat


%2 is used in the Hyperlink call to supply something for the targetting alias and set the URL text.
Unknown2005-11-16 05:03:15
Ah I understand now. The four wildcards just threw me off, that's all.
Unknown2005-11-16 05:28:35
Erm, right - there are four of them it seems. The third contains the spaces between the quoted part and the description part. The rest of the string is in the fourth. Pretty redundant, but at least it works doh.gif
Unknown2005-11-16 05:42:56
You can also increase the usefulness of this by scripting around it. For example, you can make it grab things by clicking on their links in IH. To do this add another targetting alias, for example "tg *" (for "target get"), make that alias send to script something along those lines (all in Lua):

CODE

SetVariable("target_prev", GetVariable("target"))
SetVariable("target", "%1")


Presuming that your main target variable is named plainly "target". Make the Hyperlink in the plugin call that alias instead of the main one. Then add another alias, for example "targ-get" and make it send to script:

CODE

Send("get @target")
SetVariable("target", GetVariable("target_prev"))
SetVariable("target_prev", "")


Now, create an Accelerator, for example "CTRL+g" and make it call the "targ_get" alias. Then you'll be able to click on a link in IH and tap CTRL+g to get whatever you need. Your target will be automatically reset to whatever it was before you clicked on a link as a result of that sequence of actions. You can obviously set up any number of alias-accelerator pairs for any number of actions in this fashion, like GREET @TARGET, PROBE @TARGET, etc.
Unknown2005-11-19 05:51:18
Can't get this working at all. Le sigh. Nevermind, I made a typo. Yay me.
Unknown2005-11-19 06:47:34
QUOTE(Avator @ Nov 16 2005, 04:42 PM)
You can also increase the usefulness of this by scripting around it. For example, you can make it grab things by clicking on their links in IH. To do this add another targetting alias, for example "tg *" (for "target get"), make that alias send to script something along those lines (all in Lua):

CODE

SetVariable("target_prev", GetVariable("target"))
SetVariable("target", "%1")


Presuming that your main target variable is named plainly "target". Make the Hyperlink in the plugin call that alias instead of the main one. Then add another alias, for example "targ-get" and make it send to script:

CODE

Send("get @target")
SetVariable("target", GetVariable("target_prev"))
SetVariable("target_prev", "")


Now, create an Accelerator, for example "CTRL+g" and make it call the "targ_get" alias. Then you'll be able to click on a link in IH and tap CTRL+g to get whatever you need. Your target will be automatically reset to whatever it was before you clicked on a link as a result of that sequence of actions. You can obviously set up any number of alias-accelerator pairs for any number of actions in this fashion, like GREET @TARGET, PROBE @TARGET, etc.
224016



I don't suppose you could mesh this all together with your plugin? I suck at this coding thing and I am afraid I will, I don't know, launch a nuke at my house tongue.gif. Slightly exagerrated, but yaknow.
Unknown2005-11-19 09:24:43
The thing is that the target variable needs to be accessible to you where and how it needs to be accessible. If I put this into the plugin then you'll still need to create the aliases where they'll be able to manipulate the variable, meaning where the variable exists. I could create an extra target variable inside the plugin, but then the plugin will work only on itself, without affecting the rest of your setup.

So in essence, the changes that are needed are specific to an individual setup, while the plugin collects only those things that can be applied universally to any system that hosts it. Besides, the changes involve only two additional aliases and one extra line in your script file, I doubt that they can cause any damage, and even if they do - they would be very easy to reverse.