Mapper Woes

Posted by Lmclarke on Fri 12 Jan 2018 09:37 AM — 22 posts, 87,550 views.

#0
Continuation of this thread, just a billion years later:
https://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=13823


Quote:
room.hovermessage = string.format (
"%s\t[ Exits: %s ]\n[ Air exits: %s ]\n\n%s",
room.name,
table.concat (texits, ", "),
uid:sub (1, 5),
room.description
)


I started using Nick Gammon's Lands of Redemption Mapper, because it seemed very close to what I needed. The above doesn't seem to work. It actually seems to "crash" the miniwindow somehow, in that once the plugin is installed uninstalling it doesn't remove the window, it can't be moved, etc.

What the above should be matching:

Quote:
The Royal Parlour
[Chilly]
Polished rosewood paneling lines the walls of this spacious and elegant
parlour. Though it is somewhat more modest than expected, particular
attention has been paid to the quality of materials in its decoration,
providing a rich, but subtle atmosphere that compliments the rest of the
Town Hall. A large hearth occupies the room's eastern wall, while solid
bronze candle holders line the perimeter of the room at regular intervals.
Along the south wall is a set of four large, floor-to-ceiling windows, each
curtained with silver-on-midnight brocade curtains. On the room's western
wall, one single, large panel has been fitted into its centre and painted
the crest of House ab Samael: a silver-painted hawk displayed upon a
black-and-silver chequered field. A single door leads back into the
central balcony.

In the last year:
(The room is cool as befits the time of year and has the neatness of a place
only recently occuppied, rather any sense of being 'lived in'. )

[ Exits: north ] [ Air exits: none ]
#1
I'll be spending my day reading and rereading this to try and get it through my thick skull this time:
http://www.gammon.com.au/forum/?id=12635
Australia Forum Administrator #2
Closing a plugin doesn't remove any associated miniwindows because, strictly speaking, a miniwindow doesn't "belong" to any plugin. That's why the documentation suggests putting the plugin ID into any miniwindows made by that plugin to stop name clashes. To close all miniwindows (so you can see what is on the screen) you can run this alias (close_miniwindows):


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

if WindowList() then
  for _, v in ipairs (WindowList()) do 
    WindowDelete (v) 
  end
end -- if any

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


Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


If you have other windows you want to leave open you could add some sort of "if" test, eg.



if WindowList() then
  for _, v in ipairs (WindowList()) do 
    if string.match (v, "_mapper") then
      WindowDelete (v) 
    end -- if a mapper window
  end
end -- if any





As for your problem, perhaps one of the things in the hovermessage is nil? Try printing each thing first and debugging, eg.


print (room)     --> should be a table
print (room.name)  --> should be a string (not nil)
print (texits)   --> should be a table
print (uid)      --> should be the room ID
print (room.description)  --> should be a string (not nil)
Australia Forum Administrator #3
Lmclarke said:

What the above should be matching: ...


The other thing is, what you posted won't "match" anything. It isn't code that does a match. It does a format, which is designed to make a "hover" tooltip when you mouse over a room.

To do matching you would expect to see string.match or string.find function calls.
#4
I think I completely misunderstood how the trigger is supposed to work. On the miniwindows - that is VERY helpful to me, thank you, Nick.

I managed to get through the guide to setting up a mapper to the point of "integrating for your own MUD", then got myself stuck with the UID/hashing portion -- not terribly far, unfortunately.

The administrator on the MUD I hoped to design the mapper for has agreed to let players have access to room vnum via a prompt variable, however, so that is going to sap the great, great majority of "nightmare mode" out of this.

Thank you as always for responding. I'm hoping that once the above change goes through I'll be able to work through it with a little more success.
Amended on Sat 13 Jan 2018 11:24 AM by Lmclarke
#5
Okay, got through the guide now that vnums are available. Sadly, it's obvious I'm doing something wrong.

This is what I have:
https://pastebin.com/Nhx2uLQ7

While it does appear to draw the room I'm in, walking around doesn't draw any other rooms. They don't draw at all, even if I stop and do an extra "look."

If I changed the color number to anything but 9, it grabs the word "fresh" from my prompt and seems to think that's the room name. I tried with every single other color. All of them but 9 grabbed "fresh." This was baffling. For reference, prompts look like this:

<RPXP Gain: Average> <HP:perfect MV:fresh P:walk> <Room: 11094> (bathed)


With the color set to 9, it grabs the "temperature" from the top of the room but not the room name. This is probably because the brackets around the temperature are also bold red. Can I make it skip triggering on anything that starts with a [ bracket?
Amended on Sat 13 Jan 2018 09:47 PM by Lmclarke
#6
I went back and changed the "match" on the prompt trigger to this:

match="*&lt;RPXP Gain: *&gt; &lt;HP:* MV:* P:*&gt; &lt;Room: *&gt;*"


Same issues, unfortunately.
Australia Forum Administrator #7
Can you paste the actual trigger please?

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


(Not the whole plugin, but the part you are expecting to match, which doesn't).

As for the rooms not being linked, it is probably (almost certainly) that you are not associating exits with rooms, and where they go.

As I think my tutorial mentioned, you need to detect when you change rooms (that is easy enough because the vnum changes) and then put in an exit from one room to the other.

eg.

  • You were in room 1000.
  • You go east (eg. you type "e")
  • You are now in room 1001


Therefore room 1000 has an east exit that leads to 1001. That needs to go into the rooms table, so that when the mapper asks what exits a room has, you can tell it "room 1000 has an east exit to 1001".

Look at the tutorial you referenced, around where there is a comment in the code "-- if we changed rooms assume that our last movement sent us here".
Australia Forum Administrator #8
Quote:

Therefore room 1000 has an east exit that leads to 1001.


Also, you can probably assume, which my code did, that going west from 1001 takes you to room 1000.
#9
The trigger for prompt:

<triggers>
  <trigger
   enabled="y"
   match="*&lt;RPXP Gain: *&gt; &lt;HP:* MV:* P:*&gt; &lt;Room: *&gt;*"
   script="got_prompt"
   sequence="100"
  >
  </trigger>
</triggers>


Trigger for room name:

<triggers>
  <trigger
   back_colour="8"
   bold="y"
   enabled="y"
   keep_evaluating="y"
   match="*"
   match_back_colour="y"
   match_bold="y"
   match_inverse="y"
   match_italic="y"
   match_text_colour="y"
   sequence="90"
   text_colour="9"
   script="got_room_name"
  >
  <send>say test of room name, which should be %1</send>
  </trigger>
</triggers>


I added the test in there to see what was happening. It IS pulling up the room name, apparently, but it goes on to grab the line below it as well (it starts with a bold red bracket). Policy is the room name, the line below is the "temperature":

Maker claims, "Test of room name, which should be Policy"
Maker states, "Test of room name, which should be [Play by the rules, but be ferocious."] "


I'm wondering if because movement from room to room is delayed on the MUD (e.g. You type "north", and this happens: "Maker begins to move north. Maker crosses the center of the room at a walk. Maker leaves north. Maker arrives from the south.") it might present some unique issues on the map drawing front?
Amended on Sun 14 Jan 2018 12:15 PM by Lmclarke
Australia Forum Administrator #10
Quote:

... but it goes on to grab the line below it as well (it starts with a bold red bracket).


They both start with bold red? Just ignore lines that start with the bracket.
#11
Fully revealing how bad I am at this, here, but how do I approach that? I read in the triggers/fun with triggers threads that I can accomplish it with ?! before the bit I want to avoid, but when I attempted it I must have done it incorrectly.

What I tried:
^\?![*$
Amended on Sun 14 Jan 2018 08:16 PM by Lmclarke
Australia Forum Administrator #12
The simple thing would be to match everything and in the script discard any line that starts with a bracket. However you can make a regexp to do it:


^[^\[]


That matches any line that starts with any character except a left square bracket.

You need the backslash to "escape" the bracket inside the brackets.

The thing in square brackets is a "set" and by putting a carat at the start of the set you negate the set.

http://www.gammon.com.au/regexp

For example:


[abc]


Matches "a", "b" or "c" (in a single character) and:


[^abc]


Matches any single character except "a", "b" or "c".
Amended on Sun 14 Jan 2018 08:49 PM by Nick Gammon
Australia Forum Administrator #13
If you want to capture the matching line add some round brackets:



^([^\[].*)$
Australia Forum Administrator #14
What are the MUD details (IP and port)? I might take a poke around and see what it does. Also how do you put the vnum into the prompt?
#15
ti-legacy.com port 5050

You add the vnum into the prompt with the %R variable!
Australia Forum Administrator #16
To get you started I have done a preliminary mapper for The Inquisition.

For this to work I changed my prompt to:


prompt {c{[RPXP Gain: %X] {[HP:%h MV:%v P:%p] %f %o{x (vnum %R) %c


Basically that is the standard prompt with "(vnum %R)" at the end. If you have a different prompt you'll need to change the prompt trigger. It also assumes that the vnum is wildcard #6 on the prompt trigger. If not change the "6" in the plugin to be whatever wildcard your vnum is.


uid = wildcards [6]


I have moved the source code to GitHub:

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

The main GitHub page for this plugin is at: https://github.com/nickgammon/plugins/blob/master/Inquisition_Mapper.xml.

There you will find the commit history and other information.




Example of it in use after a bit of wandering around:



Basically it detects room names, vnums, descriptions, and exits. You could add in more stuff (eg. shops) with a bit more work. There is also an alias "mapper find xxx" which does a simple search of room names. For example:


mapper find baker


This returns (for me):


Synthia's Bakery - 6 rooms away
A Lounge in the Bakery - 7 rooms away


[EDIT]

Caveats for use


The detection of which rooms leads to which depends on detecting that you type a movement command (eg. "n"), that your room number (vnum) changes, therefore that room A leads to room B by the direction you used. It also assumes that B leads back to A by the inverse direction (so if you go north to get to B, you go south to get back to A).

If you type multiple directions (ie. try to speedwalk) then it will get confused as the later direction will be considered the one which took you to the room.

So, for walking around mapping, type a single direction and then wait until you arrive. You can however "speedwalk" using the mapper (you can do this by clicking on any room in the map, or by using the "mapper find" command and clicking on a hyperlink).

Movement done by the mapper is "paced" so that it waits until you change rooms before sending the next movement command. Therefore it is fine to use the mapper speedwalk to get as quickly as you can from parts of the existing mapped rooms to a starting point for doing more mapping.

Prompts and output format


I tested this plugin with the default settings for a new character, except I modified the prompt as described above to show the vnum. If you have a modified prompt, or your prompt changes, you will probably need to change the trigger that matches the prompt (the line with the vnum). You could possibly have multiple triggers that match multiple prompt lines (for example, an in-combat line and an out-of-combat line). Multiple triggers will not be a problem, as they can all call the same script function.

I also detected a few special lines, which may possibly be drawn differently if you change your character configuration. In particular:

  • The prompt, naturally, which conveys the vnum. You don't have to use the word "vnum" in your prompt, possibly something else like "$$$12345$$$" would be less intrusive. If you change that, change the appropriate trigger match text.
  • The "new room" message which is bold text, in red text on a black background
  • The "weather" line which is also bold red text on a black background, and starts with a square bracket
  • A blank line after the room description (which itself follows the "weather" line, and separates the description from other things like "Dark clouds loom on the horizon" which are not part of the room description.
  • The "exits" line which reveals which exits the room has (which is used to pre-seed the available exits). This is in not bold, cyan text on a black background.
  • A couple of lines which indicate you are resting or asleep, if you try to move when in those states. I presume there would be other, similar one. So far they have appeared in bold yellow on black. There is a table of such messages (see below) which you can add to.


If you don't see anything much happening in the mapper review your configuration, or change the triggers to match how you have your game experience set up.

Debugging information


When a new room is added to the database you should see a line in your output window, in green, like this:


Added room <Entrance to the Merchants' Guildhall> (vnum 3403) to the mapper database


If that is annoying you can "comment out" (or delete) this line in the code:


    mapper.mapprint (string.format ("Added room <%s> (vnum %s) to the mapper database", room_name, uid))


You can "comment out" a line by putting "--" at the start of that line.


Things that prevent you from moving


Certain conditions (like resting, sleeping, etc.) prevent you from moving. The mapper needs to know what those messages are, otherwise it thinks you are moving and won't let you move somewhere else. Inside the plugin is a table of such messages, like this:


local cannot_move_messages = {
    "Nah... * feels too relaxed...",
    "In * dreams, or what?",

-- add more here

    }


To add more just add more lines like the above, using "*" as a wildcard if necessary (eg. instead of your name). If you find the mapper thinks you are walking when you aren't, type "mapper stop" to cancel the current speedwalk. You can also use "mapper stop" if you have started speedwalking and change your mind.

Once you have added more messages reload the plugin (File menu -> Plugins -> choose the Mapper plugin -> click "Reinstall"). If there are some other standard messages you are welcome to let me know what they are (copy and paste please!) so that updated versions of the plugin will include them.

Getting help


Type: "mapper help" for a quick summary of commands that can be used to talk to the mapper.
Amended on Tue 16 Jan 2018 04:17 AM by Nick Gammon
Australia Forum Administrator #17
For simplicity the plugin serializes the mapper data to the plugin save file. This means it is retained from one session to the next, although there is a slight possibility you might lose the data if the power fails while the save file is being written out. You might want to back up the plugin "save state" file from time to time (eg. daily).

To find the save state file name, RH-double-click the plugin in the list of plugins dialog box.
Amended on Mon 15 Jan 2018 02:28 AM by Nick Gammon
#18
Thank you so much for your (above and beyond) help with this. I'm going to keep at it and see if I can't whip together some of the excess features you referenced in the mapper guide, and suffice to say I would not have been able to get to do that without the above. Thank you, again! I'm so excited to try it out.
Amended on Mon 15 Jan 2018 03:31 AM by Lmclarke
Australia Forum Administrator #19
Have fun playing!

I've enhanced it a bit since my earlier post:

  • It now captures room descriptions which show up if you hover the mouse over a room.
  • You can search for the contents of a room description (eg. "mapper find shop" where "shop" is in the description)
  • Added a few utility aliases like zooming in and out (which you could bind to a macro key)
  • Added "mapper goto xxx" which lets you go to a vnum
  • Added "mapper where xxx" which tells you the speedwalk to take to get from where you are to the nominated vnum
  • Added "mapper hide" and "mapper show" to temporarily hide or show the map
  • Added "mapper stop" to cancel speedwalking
  • Added detection that you are resting or asleep. You may need to add more of those, just follow the guidelines for the current triggers.
  • Added a notice when you load it about what the name of the "save state" file is so you know what file to back up regularly.
Australia Forum Administrator #20
I moved the plugin source to Github (link in earlier post). This makes it easier to keep track of changes.

You can also see the gradual development of the plugin by looking at the commit history. The initial commit was 335 lines, and the current version is 635 lines.

A fair bit I copied and pasted from other similar mappers.

The early commits show a more minimal version, and the later commit show how you can gradually add extra stuff.
#21
Fantastic! Thank you!