| Message |
Below is a simple plugin that lets you access a Thesaurus from MUSHclient.
You need to find the actual thesaurus yourself, I used one from this page:
http://www.dcs.shef.ac.uk/research/ilash/Moby/mthes.html
If you download the file 'mthes.tar.Z' (and unzip it with WinZip or similar) you will find two files inside it. The one used in the plugin is 'mobythes.aur', which the plugin expects to find in the same directory as the MUSHclient.exe program. You can modify the plugin if you want to put the thesaurus file somewhere else.
[EDIT]
That file may not work if it has "Mac" line endings. If you have trouble with it, try this file:
http://www.gammon.com.au/files/mushclient/mobythes.zip (8.8 Mb)
When the plugin is loaded it reads the entire thesaurus file, building up an "index" of where each word is in the file. This takes about a second.
After that, you can lookup any word by typing "lookup word".
Or, you can type "lookup" on its own to be prompted for the word.
If the word is found, a listbox is presented showing all the words found in the thesaurus matching that word. If you select one and click OK it will be copied to the clipboard.
In order for the plugin to be able to use the Lua io table to do the reading of the file, you have to mark the plugin as "trusted" in the Global Preferences -> Lua, like this:
local trusted_plugins = {
[""] = "", -- trust main script (ie. if no plugin running)
["03ca99c4e98d2a3e6d655c7d"] = "Chat",
["982581e59ab42844527eec80"] = "Random_Socials",
["4a267cd69ba59b5ecefe42d8"] = "Installer_sumcheck",
["83beba4e37b3d0e7f63cedbc"] = "Reconnecter",
["fed86e24fd1ed8a47d97ecb6"] = "Thesaurus", --> add this line
} -- end of trusted_plugins
This is the plugin, copy between the lines and save it as Thesaurus.xml, then install that using the Plugin installer under the File menu:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, October 13, 2006, 8:55 AM -->
<!-- MuClient version 3.80 -->
<!-- Plugin "Thesaurus" generated by Plugin Wizard -->
<muclient>
<plugin
name="Thesaurus"
author="Nick Gammon"
id="fed86e24fd1ed8a47d97ecb6"
language="Lua"
purpose="Lookup a word in a thesaurus"
date_written="2006-10-13 08:54:06"
requires="3.80"
version="1.0"
>
<description trim="y">
<![CDATA[
Type:
lookup
or
lookup <word>
eg.
lookup eat
]]>
</description>
</plugin>
<!-- Aliases -->
<aliases>
<alias
match="^lookup( (?P<word>.*)){0,1}$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>-- find the word they want
local word = "%<word>"
if #word == 0 then
word = utils.inputbox ("Word to lookup in Thesaurus?", "Thesaurus")
end -- word not supplied
-- nil if dialog cancelled
if not word then
return
end -- cancelled dialog
-- see if in index
local pos = thes [word:lower ()]
-- don't know that word?
if not pos then
utils.msgbox ("The word '" .. word .. "' is not in the Thesaurus", "Not Found")
return
end -- not found
-- seek to it in the main file
thes_file:seek ("set", pos)
-- read that line
local line = thes_file:read ()
-- convert into table
local t = utils.split (line, ",")
-- display in list box
local choice = utils.listbox (
"Matching words for '" .. word ..
"'\\n\\nClick OK to copy to the clipboard", -- message
"Thesaurus: " .. word, -- title
t) -- table of words
if choice then
SetClipboard (t [choice])
end -- if one chosen
</send>
</alias>
</aliases>
<!-- Plugin help -->
<aliases>
<alias
script="OnHelp"
match="Thesaurus:help"
enabled="y"
>
</alias>
</aliases>
<script>
<![CDATA[
function OnPluginInstall ()
thes = {}
local name = GetInfo (66) .. "mobythes.aur"
thes_file = io.input (name)
repeat
local pos = thes_file:seek () --> where we are
local line = thes_file:read () --> read a line
if line then
local w = string.match (line, "[^,]+")
thes [w:lower ()] = pos
end -- of having a line
until not line
ColourNote ("white", "blue", "Thesaurus loaded")
end -- OnPluginInstall
function OnHelp ()
world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
end
]]>
</script>
</muclient>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|