[Home] [Downloads] [Search] [Help/forum]

MUSHclient scripting

Description of MUSHclient world function: world.AcceleratorList

Name AcceleratorList
Type Method
Summary List defined accelerators
Prototype VARIANT AcceleratorList();

View list of data type meanings


Returns an array of all the accelerator keys currently defined, in the format:

keystroke = text<tab>[sendto]


Ctrl+E = eat meat<tab>[0]
Ctrl+F = follow
Ctrl+K = 4s 3e<tab>[11]
Ctrl+B = DoAfter(5, "sigh")<tab>[12]

If the "send to" field is "send to execute" (which is 10) then it is omitted (as in the "follow" example above), for backwards compatibility with versions of MUSHclient prior to 4.27.

Version 4.27 implemented the AcceleratorTo function, which lets you specify where the accelerator text is sent to.

If "send to" field is not 10 then the "send to" field number is specified as a number in square brackets at the end of the text, preceded by the tab character (hex 0x09).

The "SendTo" argument specifies where the text is to be sent to when you press the accelerator key. It can be one of:

0: World
1: Command window
2: Output window
3: Status line
4: Notepad (new)
5: Notepad (append)
6: Log File
7: Notepad (replace)
8: Command queue
9: Send To Variable
10: Execute (re-parse as command)
11: Speedwalk (send text is speedwalk, queue it)
12: Script (send to script engine)
13: Immediate (send to world in front of speedwalk queue)
14: Script - after omit (send to script engine, after lines have been omitted)

Note: Available in version 3.53 onwards.

VBscript example
dim accList

arrList = world.AcceleratorList

If Not IsEmpty (accList) Then
  For Each a In arrList 
    world.note a

End If
Lua example
-- simple example

for _, v in pairs (AcceleratorList ()) do 
  Note (v) 

-- complex example - filters on a supplied string

function FindCommand (what)
  -- search all accelerators for wanted string
  for _, v in pairs (AcceleratorList ()) do
    if string.find (string.upper (v), string.upper (what), 1, true) then
      print (v)
    end	-- if
  end  -- for
end   -- function

FindCommand "eat"

-- example of extracting out the keystroke, what is sent, and where it is sent:

accels = AcceleratorList ()

if accels then
  for _, v in ipairs (accels) do

    local keystroke, what, where = string.match (v, "^(%S+) = (.*)%[(%d-)%]$")
    if where then
       where = tonumber (where)
       keystroke, what = string.match (v, "^(%S+) = (.*)$")
       where = sendto.execute
    end -- if

    print ("keystroke =", keystroke)
    print ("what =", what)
    print ("where =", where)

  end -- for

end -- if

-- another example that turns the result into an easier-to-use table:

local accels = AcceleratorList ()
local taccels = {}

if accels then
  for _, v in ipairs (accels) do

    local keystroke, what, where = string.match (v, "^(%S+) = (.*)%[(%d-)%]$")
    if where then
       where = tonumber (where)
       keystroke, what = string.match (v, "^(%S+) = (.*)$")
       where = sendto.execute
    end -- if

    taccels [keystroke] = { send = what, where = where }

  end -- for

end -- if

tprint (taccels)
Lua notes
The example above shows how you might search for accelerators matching a particular string.

The latter examples shows extracting out the original keystroke, send text, and where it is sent.

Note that the accelerator list is numerically keyed, not keyed by the keystroke.
Returns If there are no accelerators defined then the return value is empty. Use "IsEmpty" to test for this possibility.

Otherwise, it returns a variant array containing the keystrokes and contents of each accelerator.

Use "lbound" and "ubound" to find the bounds of the array of list (ie. the number of accelerators in the list).
Introduced in version 3.53

See also ...

Function Description
Accelerator Add or modify an accelerator key (keystroke to command mapping)
AcceleratorTo Add or modify an accelerator key - with "Send To" parameter

Search for script function

Enter a word or phrase in the box below to narrow the list down to those that match.

The function name, prototype, summary, and description are searched.

Search for:   

Leave blank to show all functions.

Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes

Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes

View all functions


Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]