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

MUSHclient scripting

Description of MUSHclient world function: world.SpellCheckCommand

Name SpellCheckCommand
Type Method
Summary Spell checks the text in the command window
Prototype long SpellCheckCommand(long StartCol, long EndCol);

View list of data type meanings


This function lets you call the MUSHclient spell-checker from a script to check the command window.

The intention here is to let you filter out commands that would naturally fail the spell check, and only check ones you want. eg. "say xxx"

You can specify a start and end column (these are 1-relative, that is the first column is column 1). You can use these to remove special words that might be at the start of the command.


SetRoomDesc "this is my description"

In this case you might make an plugin that matches on:

SetRoomDesc "*"

Inside the plugin you could work out the start and end column for the "real" text and specify that for the spell checker.

If the start column or the end column is less than 1, or the end column is not greater than the start column, then the entire command window will be checked.

eg. to check the entire command window: SpellCheckCommand (0, 0)

The function returns:

-1 : spell check engine not initialised successfully

0 : spell check cancelled

1 : spell check completed OK

The spell checking is done with the currently-configured spell-check options (eg. whether words in capitals are checked, whether duplicates are checked).

If there is a spelling error in the selected text, a GUI window will pop-up requesting corrective action.

The the Lua example below for a suggested way of conditionally spellchecking certain commands. Make a plugin, and in that plugin put the function OnPluginCommand. This is called every time you send a command to the MUD.

In the script below it does a regular expression check to find what command you have entered. In the example if you "say" or "tell" something, then the "something" part (the captured pattern) is sent to SpellCheckCommand with the start and end column being those from the regular expression capture.

If the check fails, it returns false to stop sending the command.

If the check succeeds, it gets the command text from the command window, in case the spell check changed it.

If it changed, it returns false to stop *this* command being sent, and does a "Send" of the modified one.

If it didn't change (ie. no spelling errors at all, or the errors were ignored) then the original command is allowed to proceed.

Note: Available in version 3.54 onwards.

VBscript example
result = SpellCheckCommand (5, 20)

if result = 0 then
  Note "spelling error detected"
end if
Lua example
function OnPluginCommand (sText)

  a, b, c = rex.new ("(?:say|tell) (.+)"):exec (sText)

  if a == nil then
    return true  -- not matched our regular expression
  end	-- if

  -- matched regular expression - check the command
  check = SpellCheckCommand (c [1], c [2])

  -- if check failed, cancel sending
  if check == 0 then
    return false	-- cancelled, don't process

  -- if command hasn't changed, allow it to go
  if GetCommand () == sText then
    return true

  -- get the amended command, send that instead
  Send (GetCommand ())
  return false

Returns -1 : spell check engine not initialised successfully

0 : spell check cancelled (cancel button pressed)

1 : spell check completed OK (possibly after amending the text in the window)
Introduced in version 3.54

See also ...

Function Description
AddSpellCheckWord Adds a word to the user spell check dictionary
SpellCheck Spell checks an arbitrary string of text

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]