Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ General
➜ Alias menus using the word under the mouse (like zMUD speed menus)
Alias menus using the word under the mouse (like zMUD speed menus)
|
Posting of new messages is disabled at present.
Refresh page
Pages: 1 2
Posted by
| Hunter Green
USA (16 posts) Bio
|
Date
| Wed 03 Dec 2008 05:32 PM (UTC) |
Message
| Newbie to MUSHclient but an experienced developer with zMUD and other systems. One MUSH I play on requires very little by way of scripting, so I'm using it to try out MUSHclient. Only one thing I'm finding myself missing from zMUD is speed menus.
In zMUD I can create items on a menu I get by right-clicking in the MUD output window, similar to MUSHclient's menu aliases, but with one feature I can't figure out how to replicate in MUSHclient. I can include the special variable %selword in the alias to refer to whatever word was under the mouse when I clicked.
This is great for, for instance, commands that refer to the names of people I see in rooms or pages. I can easily pull up information about them without having to type names or even copy and paste them, just two clicks. You can't use triggers for this because names can appear in lots of places and could be names you don't know.
Is there any way to build similar functionality in MUSHclient? Preferably without a lot of scripting as I am trying to stick to simple things for now until I get used to them. | Top |
|
Posted by
| Onoitsu2
USA (248 posts) Bio
|
Date
| Reply #1 on Wed 03 Dec 2008 07:29 PM (UTC) |
Message
| one way i've made something is to use the %c replacment, and set in the options that auto copy selection to clipboard, and then make a macro that you can press, like CTRL+M or something similar, including the F-Keys, and make an alias that is triggered via the macro, and well it works quite well, I would have all my attack commands, including spells and the like as macros and a special alias that had some fair scripting in it, and well I could target anything with a double click of the word, and attack it with at most 2 key presses, at least 1.
-Onoitsu2 | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #2 on Wed 03 Dec 2008 07:36 PM (UTC) |
Message
| Er, well there is not a built-in function to do exactly that.
However this particular problem was solved a while back when we wrote a plugin to copy selected text onto the clipboard. To save hunting around for it, the relevant code is below (this is in a Lua script). (From http://www.gammon.com.au/forum/?id=8052&page=2)
function CopyScript(name, line, wildcs)
-- find selection in output window, if any
local first_line, last_line = GetSelectionStartLine(),
math.min (GetSelectionEndLine(), GetLinesInBufferCount ())
local first_column, last_column = GetSelectionStartColumn(), GetSelectionEndColumn()
-- nothing selected, do normal copy
if first_line <= 0 then
DoCommand("copy")
return
end -- if nothing to copy from output window
local copystring = ""
-- iterate to build up copy text
for line = first_line, last_line do
if line < last_line then
copystring = copystring .. GetLineInfo(line).text:sub (first_column) -- copy rest of line
first_column = 1
-- Is this a new line or merely the continuation of a paragraph?
if GetLineInfo (line, 3) then
copystring = copystring .. "\r\n"
end -- new line
else
copystring = copystring .. GetLineInfo(line).text:sub (first_column, last_column - 1)
end -- if
end -- for loop
-- Get rid of a spurious extra new line at the start.
if copystring:sub (1, 2) == "\r\n" then
copystring = copystring:sub (3)
end -- if newline at start
-- finally can set clipboard contents
SetClipboard(copystring)
end -- function CopyScript
The two relevant lines in bold, you would need to change to do whatever you want to do in the alias. The first is when nothing is selected, the second is to handle the selection. Instead of SetClipboard you would do whatever you wanted with that word or string.
Probably it could be reworked like this:
function GetSelection()
-- find selection in output window, if any
local first_line, last_line = GetSelectionStartLine(),
math.min (GetSelectionEndLine(), GetLinesInBufferCount ())
local first_column, last_column = GetSelectionStartColumn(), GetSelectionEndColumn()
-- nothing selected, do normal copy
if first_line <= 0 then
return nil
end -- if nothing to copy from output window
local copystring = ""
-- iterate to build up copy text
for line = first_line, last_line do
if line < last_line then
copystring = copystring .. GetLineInfo(line).text:sub (first_column) -- copy rest of line
first_column = 1
-- Is this a new line or merely the continuation of a paragraph?
if GetLineInfo (line, 3) then
copystring = copystring .. "\r\n"
end -- new line
else
copystring = copystring .. GetLineInfo(line).text:sub (first_column, last_column - 1)
end -- if
end -- for loop
-- Get rid of a spurious extra new line at the start.
if copystring:sub (1, 2) == "\r\n" then
copystring = copystring:sub (3)
end -- if newline at start
-- finally return the result
return copystring
end -- function GetSelection
Now if you call GetSelection from your alias it will return nil for no selection, or the selected string. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Hunter Green
USA (16 posts) Bio
|
Date
| Reply #3 on Wed 03 Dec 2008 07:53 PM (UTC) |
Message
| I haven't quite learned enough yet to know what to do with that code, but I'll figure that out. One question, though. To use this, I'd have to select the word, then fire off the menu-alias, rather than just Ctrl-Clicking on the word and choosing the alias, right? I.e., the word would have to be selected, not merely under the mouse? | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #4 on Wed 03 Dec 2008 08:43 PM (UTC) |
Message
| That's correct. The currently selected word, and where the mouse is clicked are two independent things.
BTW, more than a word might be selected, I would build in a check to reject it if the string was very long, contained newlines, etc. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Hunter Green
USA (16 posts) Bio
|
Date
| Reply #5 on Wed 03 Dec 2008 08:51 PM (UTC) |
Message
| Would there be a way to do it capturing the word the mouse is over, not the selected word? That's what I was really after in the first place. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #6 on Wed 03 Dec 2008 11:43 PM (UTC) |
Message
| There is no current provision for linking the mouse-click menu to a particular place on the screen. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #7 on Thu 04 Dec 2008 01:10 AM (UTC) |
Message
| Does that mean you are concocting something along those lines for the next version?
I love reading inbetween the lines with the most positive outlook. *grin* | Top |
|
Posted by
| Hunter Green
USA (16 posts) Bio
|
Date
| Reply #8 on Thu 04 Dec 2008 01:36 AM (UTC) |
Message
| Okay, thanks for the info. Guess I'll look into another way to do this. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #9 on Thu 04 Dec 2008 03:28 AM (UTC) |
Message
| I am having trouble visualizing how this would work. Selecting a word, sentence, line or paragraph is one thing (and may take a click or two). Doing something with that selection is another thing. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Hunter Green
USA (16 posts) Bio
|
Date
| Reply #10 on Thu 04 Dec 2008 10:36 AM (UTC) Amended on Thu 04 Dec 2008 10:38 AM (UTC) by Hunter Green
|
Message
| I don't mean to suggest that zMUD's paradigm is the only sensible one or anything, but it's the only way I can suggest how this would work, and why it would be useful.
Whenever you use the right-click menu (or "speed menu" as zMUD calls it) which is analogous to a menued alias in MUSHclient, there's just one built-in variable available which contains the word (i.e., whatever text matches the regexp for a word) that was under the mouse when you clicked. So just as you might have used %1 in an alias to refer to the parameter matched when you typed it, you can use %selword in a speed menu to refer to the word that was matched where the mouse was.
(The name "%selword" isn't as much of a misnomer as it might seem. In fact, if you have selected text before firing off one of these speed menu items, %selword contains whatever was selected -- whether it's a word, a whole line, you name it. If you haven't selected anything, it will contain just the word that's where the mouse was -- the word you would select if you had double-clicked first. So the name "%selword" is not very accurate; it's either the selection or the word!)
In other MUDs I use this primarily for things that act on other characters, or objects, since character names and objects can appear in many places in room descriptions, emotes, poses, lists, etc. and it's impossible to make triggers for them all. Thus, if I happen to see a message about a person entering the room and I'm not familiar with their name, I just right-click on the name and choose a command to show me information about them. If there's a long list of objects in a room, I can right-click on one to get or drop it or probe for more details.
I know virtually nothing about how MUSHclient handles things internally, or even externally yet, so I don't know how feasible this is. So I hope you take this explanation as merely trying to help you consider the idea, not a demand that this is the only way this function could be implemented. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #11 on Thu 04 Dec 2008 07:10 PM (UTC) |
Message
| Thanks for clarifying what you had in mind. :)
What you suggest doesn't sound overly complex - funny no-one suggested it before. I'll keep that in mind for a future version. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Shamo
(7 posts) Bio
|
Date
| Reply #12 on Tue 16 Dec 2008 05:46 PM (UTC) |
Message
| This would be quite handy! I can see how usefull it could be and strongly support this idea. | Top |
|
Posted by
| Hunter Green
USA (16 posts) Bio
|
Date
| Reply #13 on Sun 17 Oct 2010 03:29 PM (UTC) |
Message
| I had dropped out of using MUSHclient for a long time and many versions, so I'm wondering if this ever made it into one of the versions since, and if so, what I should look up in the help to find out how to use it. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #14 on Sun 17 Oct 2010 07:20 PM (UTC) |
Message
| Ah no, but thanks for reminding me. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
51,855 views.
This is page 1, subject is 2 pages long: 1 2
Posting of new messages is disabled at present.
Refresh page
top