Materia Magica mapper plugin

Posted by Nick Gammon on Tue 12 Oct 2010 04:25 AM — 28 posts, 148,661 views.

Australia Forum Administrator #0
Below is a preliminary attempt at a mapper for Materia Magica. The tricky bit, as usual, with MUDs is trying to detect when you are in a new room, and work out a room number.

In this case I looked for a yellow line (the room name) followed by a blue line with hyphens in it (the compass) followed by some gray lines (the description). Put all that together and you should have something reasonably reliable.

The exit detection is simply done by noticing you are in another room, and working out which way you came from the previous room.

When you first go to a new room it will appear disconnected, until you walk back the way you came. Then it realises that if east from A is B, and west from B is A, then A and B are connected.

Example:



The plugin is now available on GitHub.

Go to this page:

http://github.com/nickgammon/plugins/blob/master/Materia_Magica_Mapper.xml

You will see the plugin in pretty-printed XML format.

  • To get a raw copy suitable for installing, look a little way down the page to where it says:

     ... edit | raw | blame | history

  • RH-click on the "raw" hyperlink and then "Save link as" to get a local copy. (You can click on "history" to see what recent changes have been made)
  • Put the copy in your worlds / plugins folder.
  • Name it: Materia_Magica_Mapper.xml
  • Go to the MUSHclient File menu -> Plugins
  • Click "Add"
  • Choose the file Materia_Magica_Mapper.xml (which you just downloaded) as a plugin
  • Click "Close"


For exit detection you should turn on the Visible Exits line by typing into the MUD:


set show-exits


Then as you walk around you should see something like:


  Visible Exits: N E S W Nw Ne 

Amended on Tue 12 Oct 2010 09:06 PM by Nick Gammon
Australia Forum Administrator #1
The mapper plugin has been improved today to detect exits from the Visible Exits line which you can turn on (see above post). I have removed the plugin from the post and moved it to GitHub. That way you can always get the latest one.

The "history" link shows what has changed recently, when and why. Well, hopefully.

Because of the exit detection you will now see "stub" lines which show rooms that it knows exist (because there is an exit leading there) but it doesn't yet know what room is there.
#2
Awesome!

Big thank you :)
USA #3
I know it sounds terrible, but I got a chubby as soon as I read this. My MUSHClient dreams have come true, ty Nick!

The only other question, and I don't know if I asked this in another thread last night, is how will it handle dizzy rooms, looping rooms, teleporting rooms, etc?
Australia Forum Administrator #4
Basically it draws "normal" exits - teleports and funny rooms might make it either not draw them, or draw inconsistently. I haven't really addressed that sort of thing.
Australia Forum Administrator #5
I have been enhancing the mapper somewhat.



One major change is to use a SQLite database, rather than saving the map in the plugin state file.

What this does is let you share the maps much more readily - for example, if you have multiple characters they will all use the same database, so you don't have to remap every time you switch characters. Also you could conceivably dump the database into a text file (see "Backing up your database" on http://www.gammon.com.au/db) and then email that to someone else to incorporate into theirs (effectively, merging your database with theirs).

Some other improvements:

  • Shops are marked in darker brown (see example above) so you can more easily find them
  • Trainers are marked in yellow
  • You can RH-click to add bookmarks (eg. "quest")
  • You can search for shops, trainers or for any word in the room name or room description, eg:

    
    mapper shops
    
    Devon's Herbs (BBDF9F09FD) - 8 rooms away
    Tolin's Weapons (E5DFB9CC5F) - 8 rooms away
    Telgan's Tavern (3DACF5215A) - 9 rooms away
    Shrine of St. Wisehart (0B0408C190) - 12 rooms away
    Savonty's Barbershop (76E5347C13) - 13 rooms away
    Galbo's Armor (D9ADD4A960) - 14 rooms away
    The Hungry Goat Inn (7307E97D8E) - 15 rooms away
    The Bank of Rune, Lasler Branch (CED07B0B8B) - 16 rooms away
    General Store (43AA57A385) - 16 rooms away
    
    
    mapper train
    
    
    Hall of Training (79F3C09702) - 11 rooms away
    Hall of Training (B7FD218B1D) - 12 rooms away
    There were 2 matches which I could not find a path to within 30 rooms.
    
    
    
    mapper find irvin
    
    
    Bedroom (FA2A468D8C) - 1 room away
    Living Room (068C303A14) - 2 rooms away
    Cramped Closet is the room you are in
    Master Irvin's Office (5C862533CB) - 3 rooms away
    
    

  • Shops and trainers are auto-detected as you walk around
  • It detects lines like "The door is closed." and then automatically opens the door.


You could do more, but this should give you something to play with.

The new version is available from GitHub, link given above.
Amended on Wed 13 Oct 2010 04:49 AM by Nick Gammon
USA #6
Hey Nick,

I installed this updated plugin but I got a few errors. Upon initial loading:

Run-time error
Plugin: Materia_Magica_Mapper (called from world: Materia Magica - Forral)
Function/Sub: Other_Line called by trigger
Reason: processing trigger "Other_Line"
[string "Plugin"]:658: table rooms has no column named desc
stack traceback:
[C]: in function 'error'
[string "Plugin"]:593: in function 'dbcheck'
[string "Plugin"]:658: in function 'save_room_to_database'
[string "Plugin"]:179: in function <[string "Plugin"]:103>
Error context in script:
654 : function save_room_to_database (uid, title, desc)
655 :
656 : assert (uid, "No UID supplied to save_room_to_database")
657 :
658*: dbcheck (db:execute (string.format (
659 : "INSERT INTO rooms (uid, name, desc, date_added) VALUES (%s, %s, %s, DATETIME('NOW'));",
660 : fixsql (uid),
661 : fixsql (title),
662 : fixsql (desc)
You have entered "The Separatists Clan Hall".
Trigger function "Other_Line" not found or had a previous error.
[*][SAFE]<3087hp 2500sp 1692st> [ 0 * 0 * 22 ]
Trigger function "Other_Line" not found or had a previous error.
l


And that line "Trigger function "Other_Line" not found or had a previous error" repeats itself after every single line.

Thanks,
Forral
Australia Forum Administrator #7
For a minute I thought I must have forgotten to create that column "desc" but it gets created with everything else. I don't really understand that. What version of MUSHclient are you using?

Can you please:

  • Remove the plugin (so the database isn't in use)
  • Delete the database (materiamagica.com_23.db) from your MUSHclient directory (the number 23 might be different depending on what port you connect on).
  • Re-install the plugin


Let me know of any other error messages (like, when first starting).
Australia Forum Administrator #8
I can see one potential problem. Maybe "desc" is a reserved word, although it works for me.

[EDIT] The word "DESC" is indeed an SQL word (short for descending) so I am puzzled why it ever worked. I am guessing your version of the SQLite engine was earlier and does not allow "desc" in that way. If you had a version of MUSHclient which is 4.60 or earlier this might be the case.

I've updated the plugin to use "description" instead. Try grabbing the latest plugin (it should be version 1.2) and then follow my instructions above to delete the database and start again (it needs to make a new database with "description" rather than "desc").

Because of this change, anyone else who is using the plugin will need to delete the database and start again. Sorry.

As an alternative (if you have already mapped a lot of rooms - this won't be you Forral) you can do this:

  • Close MUSHclient so the database is not in use.
  • Grab the "command line tool" from the SQLite3 web site, eg.

    http://www.sqlite.org/sqlite-3_7_3.zip
  • Unzip that and put sqlite3.exe into your MUSHclient directory.
  • Open a command window (Run -> Cmd), change directory to the MUSHclient directory, and type:

    
    sqlite3 materiamagica.com_23.db .dump > materiamagica.sql
    


    (The number 23 might be 4000 - it is whatever port you use to connect).
  • Use a text editor like Crimson Editor to open up the resulting file materiamagica.sql.
  • A few lines down change "desc" to "description":

    
    CREATE TABLE rooms (
          roomid        INTEGER PRIMARY KEY AUTOINCREMENT,
          uid           TEXT NOT NULL,   -- vnum or how the MUD identifies the room
          name          TEXT,            -- name of room
          description   TEXT,            -- description
          building      TEXT,            -- which building it is in
          shop          INTEGER,         -- 1 = shop here
          train         INTEGER,         -- 1 = trainer here
          notes         TEXT,            -- player notes
          date_added    DATE,            -- date added to database
          UNIQUE (uid)
        );
    

  • Further down find these lines and change "desc" to "description" in two places:

    
    INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)
    VALUES('table','rooms_lookup','rooms_lookup',0,
    'CREATE VIRTUAL TABLE rooms_lookup USING FTS3(uid, name, description)');
    CREATE TABLE 'rooms_lookup_content'(docid INTEGER PRIMARY KEY, 'c0uid', 'c1name', 'c2description');
    

  • Save your changes to materiamagica.sql.
  • Rename the original database:

    
    ren materiamagica.com_23.db materiamagica.com_23.db.old
    

  • Recreate the database from the SQL:

    
    sqlite3 materiamagica.com_23.db < materiamagica.sql
    

  • Download and install the amended plugin.
  • Start MUSHclient again and try the mapper.


That should fix up the name of the "desc" column to work with the amended plugin.

Of course, only do all this work if you have mapped hundreds of rooms - otherwise it would be quicker just to start again.
Amended on Fri 15 Oct 2010 02:21 AM by Nick Gammon
USA #9
Thanks for the fix Nick. Oddly though, its not mapping the rooms. I no longer get the error messages and I do see the message of each room being added to the database with a unique ID, but its not drawing it.

In response to your previous post I am still the latest MUSHClient, 4.64.
Australia Forum Administrator #10
As I mentioned earlier, you need to backtrack a bit. That is, when visiting a new room you are likely to just see one square. But if you backtrack it should join them. So for example, in a town, walk all the way east (you will just see single squares). Then walk west, and they will start to be connected. It doesn't assume that going east from a room means you can go west to get back there.
Australia Forum Administrator #11
Also make sure you can see the exits:


set show-exits

USA #12
Nick Gammon said:

Also make sure you can see the exits:


set show-exits




That did the trick, I forgot to re-enable it after reinstalling the plugin.

Thanks alot Nick, this really makes the game more enjoyable to play, and will help with alot of the tricky dungeons.
Australia Forum Administrator #13
Yes I see that it doesn't link rooms without seeing the exits. I've amended the plugin to warn you to turn that on, if it doesn't get the exits line.
#14
Nick, you're an animal!

This is cool stuff.
Australia Forum Administrator #15
A couple of improvements now ...

Snippets

I noticed that the SQLite database offers not only FTS (full text search) but "snippets". Now if you have used search engines you probably notice that when you search for a word that word in shown in the context it appears in the web page. This can be quite handy. For example, in the mapper if you were searching for "baker" you probably want the baker shop, not something like:


The baker used to live here.
North is the baker.
This is the tombstone of the baker.


So now if you do a "mapper find" it shows an extra line with your searched-for words in bold (using the search you can search for multiple things like "butcher OR baker").

For example:



In the above example I searched for:


mapper find shop OR trainer*


Note the use of OR (upper-case) which is required to search for this OR that (otherwise it looks for the word "or"). Also you can add an asterisk to match on trainer, trainers, etc.

Partial goto

A problem with the hashed room numbers is that they are tedious (impossible?) to type by hand. However you may want to quickly goto a common room (eg. the village square).

The goto has been amended to match on a partial room number, so instead of:


mapper goto e960d909fb


... you can now type:


mapper goto e96


The mapper will find the closest room starting with "e96" as its room number in this case. In many cases 3 or 4 digits are likely to be plenty.
Australia Forum Administrator #16
For the snippets to work you need an updated mapper module (version 2.2 onwards). This can be downloaded from:

http://github.com/nickgammon/mushclient/blob/master/lua/mapper.lua

RH-click on the "raw" link, download the file, and put it into the "lua" subdirectory under the MUSHclient directory, replacing the existing mapper.lua file.

You also need the updated mapper plugin, from this page:

http://github.com/nickgammon/plugins/blob/master/Materia_Magica_Mapper.xml

Download that as described on page 1 of this thread.
#17
I have been trying for about two hours to get this to work but I can't no matter what I do :(, I doesn't even show any rooms at all on the mapper. I am assuming you need SQLite in order for it to work and ive only tried to download it to plugin's. I have no idea how to install it using SQLite since I've never messed with SQLite. Any possible way you could post a tutorial on how to go about installing SQLite with a link then placing this file into SQLite in order to make it work? It would be greatly appreciated :)!

Thank you.
Australia Forum Administrator #18
SQLite has been built into the client for a while now. You don't need to install anything.

Template:summary

Please provide a summary of your world configuration:

  • Either use the scripting Immediate window (Ctrl+I) to execute: Debug ("summary")

    or

  • Install the Summary plugin (see "Summary" feature) and type "summary"

Then copy the resulting information from the output window, and paste into a Forum message.

You need version 4.55 onwards of MUSHclient to do this.


#19
Thank you for your quick reply :). Is this what you was wanting me to do?

MUSHclient version: 4.73
Compiled: May 8 2011.
Time now: Wednesday, November 02, 2011, 9:53 PM
Operating system: Windows XP
Libraries: Lua 5.1.4, PCRE 8.10, PNG 1.5.2, SQLite3 3.7.6.2, Zlib 1.2.5
World name: 'Materia Magica', ID: 5020a4e1a465a0f1d86eb937
-- Scripting --
Script language: Lua, enabled: yes
Scripting active: yes
Lua sandbox is 127 characters, DLL loading allowed: yes
Scripting prefix: '/'. External editor in use: NO.
Scripting for: 56.073643 seconds.
-- Triggers, aliases, timers, variables --
** Triggers: 36 in world file, triggers enabled: yes. [Triggers]
30 enabled, 5 regexp, 5094192 attempts, 8523 matched, 14.557023 seconds.
** Aliases: 41 in world file, aliases enabled: yes. [Aliases]
40 enabled, 0 regexp, 40333 attempts, 269 matched, 0.081779 seconds.
** Timers: 1 in world file, timers enabled: yes. [Timers]
1 enabled, 128 fired.
Timers checked every 0.1 seconds.
** Variables: 4. [Variables]
-- MCCP --
MCCP active, took 0.506223 seconds to decompress
MCCP received 1547580 compressed bytes, decompressed to 15517710 bytes.
MCCP compression ratio was: 10.0% (lower is better)
-- Plugins (Processing order) --
ID: 7210c1be34cf14cda8ae48c4, 'KillsTillNextLevel', (Vbscript, 0.134 s) Enabled [Tr]
ID: 565dae21eb816a2fdb8d50f9, 'Chat_Capture_Miniwindow', (Lua, 52.661 s) Enabled [Tr Al Va Cb]
** Plugins: 2 loaded, 2 enabled.
-- Comms --
Connect phase: 8 (Open). NAWS wanted: NO
Received: 1548537 bytes (1512 Kb)
Sent: 103820 bytes (101 Kb)
Received 24004 packets, sent 3508 packets.
Total lines received: 211076
This connection: Sent 3500 lines, received 211703 lines.
Telnet (IAC) received: DO: 0, DONT: 0, WILL: 8, WONT: 1, SB: 2 [Telnet]
-- MXP --
MXP active: yes, Pueblo mode: NO, Activated: On command
MXP tags received: 94375
MXP entities received: 61493
MXP errors: 0
-- Commands --
Commands in command history: 758
Speed walking enabled: NO. Speed walking prefix: #
Command stacking enabled: NO. Command stack character: ';'
Accelerators defined: 0
-- Miniwindows --
Window: '565dae21eb816a2fdb8d50f9', at (0,0,1256,202), shown: yes
width: 1256, height: 202, position: 0, hotspots: 6, fonts: 2, images: 0
** Miniwindows: 1 loaded, 1 shown.
-- Output window --
Output pixels: width 1259, height: 803, font width: 7, font height: 15
can show 179 characters, wrapping at column 160, height 53 lines.
Output buffer: 4996 of 5000 lines.
-- Miscellaneous --
Logging: NO, tracing: NO
** SQLite3 databases: 0
Sound buffers in use: 0

---------------------- End summary ----------------------
#20
I too got an error message similar to the person a few posts earlier:

Scripting error

Error number: 0

Event: Run-time error

Raised by: Plugin: Materia_Magica_Mapper (called from world: Merentha)

Description: [string "Plugin"]:731: table rooms has no column named shop
stack traceback:
[C]: in function 'error'
[string "Plugin"]:619: in function 'dbcheck'
[string "Plugin"]:731: in function 'create_tables'
[string "Plugin"]:501: in function <[string "Plugin"]:471>

Called by: Function/Sub: OnPluginInstall called by Plugin Materia_Magica_Mapper
Reason: Executing plugin Materia_Magica_Mapper sub OnPluginInstall
~~~~~~~~~~~~~
Any comments or suggestions would be much appreciated. :)

(Not sure how to go about fixing it. :( ).
Australia Forum Administrator #21
Havic said:

-- Plugins (Processing order) --
ID: 7210c1be34cf14cda8ae48c4, 'KillsTillNextLevel', (Vbscript, 0.134 s) Enabled [Tr]
ID: 565dae21eb816a2fdb8d50f9, 'Chat_Capture_Miniwindow', (Lua, 52.661 s) Enabled [Tr Al Va Cb]


Sorry for the delay. Chaos here.

I don't see the mapper plugin there.
Australia Forum Administrator #22
Gorion said:

Description: [string "Plugin"]:731: table rooms has no column named shop
stack traceback:
[C]: in function 'error'
[string "Plugin"]:619: in function 'dbcheck'
[string "Plugin"]:731: in function 'create_tables'
[string "Plugin"]:501: in function <[string "Plugin"]:471>

Called by: Function/Sub: OnPluginInstall called by Plugin Materia_Magica_Mapper
Reason: Executing plugin Materia_Magica_Mapper sub OnPluginInstall
~~~~~~~~~~~~~
Any comments or suggestions would be much appreciated. :)



Did you try another version of the mapper before? You may have a different (format) database. Try deleting the database file (close the world first so it isn't in use).

Its name will be something like "materiamagica.com_23.db" and it will be in the MUSHclient "executable" directory.
#23
Nick Gammon said:

Gorion said:

Description: [string "Plugin"]:731: table rooms has no column named shop
stack traceback:
[C]: in function 'error'
[string "Plugin"]:619: in function 'dbcheck'
[string "Plugin"]:731: in function 'create_tables'
[string "Plugin"]:501: in function <[string "Plugin"]:471>

Called by: Function/Sub: OnPluginInstall called by Plugin Materia_Magica_Mapper
Reason: Executing plugin Materia_Magica_Mapper sub OnPluginInstall
~~~~~~~~~~~~~
Any comments or suggestions would be much appreciated. :)



Did you try another version of the mapper before? You may have a different (format) database. Try deleting the database file (close the world first so it isn't in use).

Its name will be something like "materiamagica.com_23.db" and it will be in the MUSHclient "executable" directory.


Ah yes thank you for that! Deleting those .db files fixed the problem! Except when the mapper comes on, it still stays the same green window (i.e. with the text of info about it in the middle and that's it).

Looks like my mud is un-mappable haha.
#24
I get the following runtime error, and am wondering if there is a way to get this mapper to work with my MUD:

[string "Plugin"]:731: table rooms has no column named shop
stack traceback:
[C]: in function 'error'
[string "Plugin"]:619: in function 'dbcheck'
[string "Plugin"]:731: in function 'create_tables'
[string "Plugin"]:501: in function <[string "Plugin"]:471>


Thanks for the help!!

-Aaron

Australia Forum Administrator #25
You haven't said what MUD it is, but I would close the client, delete the mapper database, and start it up again. It looks like you might have an older database. With none there, it re-makes it.
#26
Pretty cool, but one major issue (besides dizzy rooms, teleport rooms, etc)

Rooms that have same description. I.e., "wilderness areas" or roads that have same descrips.. without reviewing the code, i'm assuming it disregards same descrips so that it is not fooled by room LOOK. Problem with mapper is that it does not detect movement from one room to an adjacent room with same descrip, so it has to continually remap at the "end of the street" etc. (a lot of "fixed exits" on paths that have already been mapped) The result is an erroneous map in which paths connected to either "end" are out of synch. A city block that should be rectangular is now a spiral path or something equally silly.

any idea how to resolve this particular conflict?
Australia Forum Administrator #27
Yes, that's annoying. I've done a few versions over the years, one of them incorporated the room exits to try to make the rooms unique. Not that this would always work.