Can mush access the database such as excel or access?

Posted by Phost on Mon 07 Sep 2009 06:56 AM — 3 posts, 13,507 views.

#0
hello!i always have so much problems.sorry!
now i have learned that mush can access the database such as sqlite. can mush deal with the excel or access database
what i want to do is
Name do
kitchen w;s;s;s
liveroom n;n;u
stable w;s;s;n;nw
where name and do is field of the database.

in zmud,i use the command
place=liveroom;#find @place,do=&do,#exec @do
then i can goto the liveroom
the database i already created is about 1000 records of
each place name and how to go there,but it is excel format.
how can i use it in mush?
thanks!!
Australia Forum Administrator #1
There are various ways you could do this, including using a COM object to access the Excel database, but I think this would be slow, as that would mean Excel has to load every time.

The solution below will be nice and fast. :)

  • Save the plugin below to disk as directed in the instructions.
  • Open Excel to get at your database of speedwalks, and then "save as comma-delimited" file (CSV file). That should give you a file like this:

    
    kitchen, w;s;s;s
    liveroom, n;n;u
    stable, w;s;s;n;nw
    


    Open that file in a text editor and copy those lines into the plugin, replacing the example three lines (in bold) with your 1000 or so lines.
  • Save the amended plugin (and do a plugin reinstall if you have already installed it).
  • Now you can just type "goto kitchen" and it will do the speedwalk.


If you need to add or amend speedwalks just open the plugin in a text editor and fix up the list in the speedwalks part.

Template:saveplugin=Speedwalker
To save and install the Speedwalker plugin do this:
  1. Copy the code below (in the code box) to the Clipboard
  2. Open a text editor (such as Notepad) and paste the plugin code into it
  3. Save to disk on your PC, preferably in your plugins directory, as Speedwalker.xml
    • The "plugins" directory is usually under the "worlds" directory inside where you installed MUSHclient.
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file Speedwalker.xml (which you just saved in step 3) as a plugin
  7. Click "Close"
  8. Save your world file, so that the plugin loads next time you open it.



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Tuesday, September 08, 2009, 6:59 AM -->
<!-- MuClient version 4.43 -->

<!-- Plugin "Speedwalker" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Speedwalker"
   author="Nick Gammon"
   id="fa0ecbb1922e2aa85abf94d1"
   language="Lua"
   purpose="Goes to a place from a speedwalk table"
   date_written="2009-09-08 06:58:32"
   requires="4.40"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Type : goto <place>

Edit the plugin to add more places.
]]>
</description>

</plugin>


<!--  Aliases  -->

<aliases>
  <alias
   match="goto *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

-- lookup place
sw = speedwalk_table [trim ("%1")]

if not sw then
  ColourNote ("white", "red", "Place '%1' not in database")
else
  Execute ((string.gsub (sw, ";", "\\n")))
end -- if

</send>
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[

-- trim leading and trailing spaces from a string
function trim (s)
  return (string.gsub (s, "^%s*(.-)%s*$", "%1"))
end -- trim


-- PUT SPEEDWALKS HERE BETWEEN BRACKETS:

speedwalks = [[
kitchen, w;s;s;s
liveroom, n;n;u
stable, w;s;s;n;nw
]]

speedwalk_table = {}

-- copy into table
for name, sw in string.gmatch (speedwalks, "([A-Za-z]+),(.-)\n") do
  speedwalk_table [trim (name)] = trim (sw)
end -- for

]]>
</script>


</muclient>

#2
i really love you,nick!
thank you so much!