Generic Mapping Script

All and any discussion and development of the Mudlet Mapper.
Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Generic Mapping Script

Post by Jor'Mox »

Doors in the up or down directions are, as far as I know, impossible to see on the map. Also, they are a relatively new addition to Mudlet, so if you are using an old version, they don't work. A previous version of this script had something built in to work around that problem (adding user data to the room to simulate a door in those directions), but it was removed once the functionality was added to the most recent full release of Mudlet. That said, you should be able to select the desired room on the map by clicking on it, then right click and select "exits". In the resulting window, you should see whatever exits exist, along with any relevant door status, indicated by the radio buttons below the text box with the roomID the exit leads to. For familiarity's sake, I would check this out on a room with a door in a horizontal direction, so you know what you are looking for, and so that you know it will be there.

If no door is created, but it appears to be an option, be sure to check the error window to see if something popped up when you tried to create the door with the alias. Also, try adding the door manually via the map itself, and see what happens. It is possible that I messed something up unwittingly when taking out the code that records "doors" in the up and down directions as user data, and if so I'll fix it. But it helps to eliminate as many potential problems up front, so I know what I am working with.

User avatar
ulysses
Posts: 52
Joined: Fri Jan 05, 2018 7:43 pm

Re: Generic Mapping Script

Post by ulysses »

Jor'Mox wrote:
Thu May 03, 2018 10:10 pm
Doors in the up or down directions are, as far as I know, impossible to see on the map. Also, they are a relatively new addition to Mudlet, so if you are using an old version, they don't work. A previous version of this script had something built in to work around that problem (adding user data to the room to simulate a door in those directions), but it was removed once the functionality was added to the most recent full release of Mudlet. That said, you should be able to select the desired room on the map by clicking on it, then right click and select "exits". In the resulting window, you should see whatever exits exist, along with any relevant door status, indicated by the radio buttons below the text box with the roomID the exit leads to. For familiarity's sake, I would check this out on a room with a door in a horizontal direction, so you know what you are looking for, and so that you know it will be there.

If no door is created, but it appears to be an option, be sure to check the error window to see if something popped up when you tried to create the door with the alias. Also, try adding the door manually via the map itself, and see what happens. It is possible that I messed something up unwittingly when taking out the code that records "doors" in the up and down directions as user data, and if so I'll fix it. But it helps to eliminate as many potential problems up front, so I know what I am working with.
Thanks, Jor'Mox.

I'm usuing 3.8.1 which I believe is the latest and greatest.

Let's start with simpler case if UP/DOWN are problem cases. Using another room, there is a hidden switch when pressed opens the door E. Remember my goal here is not to cope with the event of pressing the switch. I really just want to make the East exit with a door, so that if I enter the room and the east exit is not visible, the room still matches. So I create the exit using the right-click menu Exits leading to an unknown place (since when I originally mapped this room that exit was not visible, so I need to create it manually). So it's like a regular exit now. Then whilst still in that room, I type 'add door east' and this pops up in the console:

Code: Select all

Alias name=100(^add door (\w+)(?: (none|open|closed|locked)(?: (yes|no))?)?$) matched.
Alias: capture group #1 = <add door east>
Alias: capture group #2 = <east> 
Looking at the Exits menu dialog again, nothing has happened. The radio button is still on the furthest left option (i.e. no door), so either I'm messing up the command or the script is not creating the door. In this state the glowing you are here pointer on the map mis-behaves if I move away and re-enter the room since it doesn't recognise the room (the door doesn't stay open for very long). Creating the door manually using the radio buttons works in that the button stays in the place where you select it but a) the save button is always greyed out (even though it does save) and b) no symbol for the door appears on the exit - the tooltip says it should be a red symbol in the case of a locked door but I don't see anything. I have found, however, that the intended behaviour is achieved here, namely with the door set to closed or locked (but not open) the presence of the exit or not doesn't confuse the mapper when moving around! Yipee!

Now for the UP case. Even when I add a locked door in the up direction on the other room I started with, the mapper you-are-here pointer gets confused when I move into the room when not flying, so I would think that something is definitely amiss here with regard to up/down exits and either the script and mudlet Perhaps the MUDlet mapper doesn't create the door correctly? The console output looks the same as above for the E case if I try to add the door using the command line

Code: Select all

Alias name=100(^add door (\w+)(?: (none|open|closed|locked)(?: (yes|no))?)?$) matched.
Alias: capture group #1 = <add door up>
Alias: capture group #2 = <up>
Light lamp, cast light!
-Wod
CthulhuMUD
http://www.cthulhumud.com/
cthulhumud.com, port 8889
Wod :mrgreen:
CthulhuMUD
www.cthulhumud.com
A hugely entertaining MUD based on the horror writings of HP Lovecraft.

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Generic Mapping Script

Post by Jor'Mox »

Okay, so that points to two separate problems, both should be things I can address. Good. I'll dig around a bit over the next few days (probably after the weekend), and see what I can do. Hopefully I'll be able to replicate your issues, and thus fix things fairly easily. Interesting that the alias didn't report an error, and yet didn't seem to do anything.

Your goals, by the way, line up exactly with what my script tries to do, in that it only cares if there is a door, and if there is, it allows that exit to be absent when entering the room. It is interesting that changing the status of the door in the menu doesn't enable save button (I checked, it acts the same way for me, so this isn't just you), and from what I can tell, changing the door status and then closing the window in any way other than successfully clicking save doesn't save the change, so... weird, but it works regardless. For the change to become visible on the map, it needs to be forced to update, which should happen when you move, or you can also click on the map, and it should update. Adding a door should create a colored square along the line between the two connected rooms (green, yellow, or red, though all added via the alias should be yellow unless you specify a status for them). Note that even an open door should count as far as my script is concerned, so that is something else I need to look into.

If I have problems making the script behave the way you are seeing, I'll let you know. Hopefully that won't be an issue.

Edit: Oh, I just realized a potential issue that you may not have taken into account. The "add door" alias ONLY works when you are in mapping mode. If mapping is off, it does nothing, which might explain the behavior you are seeing at least in terms of the doors not being added.

User avatar
ulysses
Posts: 52
Joined: Fri Jan 05, 2018 7:43 pm

Re: Generic Mapping Script

Post by ulysses »

Jor'Mox wrote:
Fri May 04, 2018 11:28 pm
Okay, so that points to two separate problems, both should be things I can address. Good. I'll dig around a bit over the next few days (probably after the weekend), and see what I can do. Hopefully I'll be able to replicate your issues, and thus fix things fairly easily. Interesting that the alias didn't report an error, and yet didn't seem to do anything.

Your goals, by the way, line up exactly with what my script tries to do, in that it only cares if there is a door, and if there is, it allows that exit to be absent when entering the room. It is interesting that changing the status of the door in the menu doesn't enable save button (I checked, it acts the same way for me, so this isn't just you), and from what I can tell, changing the door status and then closing the window in any way other than successfully clicking save doesn't save the change, so... weird, but it works regardless. For the change to become visible on the map, it needs to be forced to update, which should happen when you move, or you can also click on the map, and it should update. Adding a door should create a colored square along the line between the two connected rooms (green, yellow, or red, though all added via the alias should be yellow unless you specify a status for them). Note that even an open door should count as far as my script is concerned, so that is something else I need to look into.

If I have problems making the script behave the way you are seeing, I'll let you know. Hopefully that won't be an issue.

Edit: Oh, I just realized a potential issue that you may not have taken into account. The "add door" alias ONLY works when you are in mapping mode. If mapping is off, it does nothing, which might explain the behavior you are seeing at least in terms of the doors not being added.
Excellent, thanks Jor'Mox. Getting this issue solved will really start to make your script and the whole mapping thing sing
If you like you could hook up to CthulhuMIUD and I could show you around, but I'm sure there are many many MUDs with hidden doors/exits.
Thinking about it, I was not in mapping mode when adding the exits, so that does indeed explain the behaviour with the command line door creation.

Best wishes,
- Wod.
Wod :mrgreen:
CthulhuMUD
www.cthulhumud.com
A hugely entertaining MUD based on the horror writings of HP Lovecraft.

User avatar
Vadi
Posts: 5041
Joined: Sat Mar 14, 2009 3:13 pm

Re: Generic Mapping Script

Post by Vadi »

The 'set character' alias is missing an extra bracket in the end of the code.

Scolius
Posts: 10
Joined: Mon Apr 30, 2018 7:24 am

Re: Generic Mapping Script

Post by Scolius »

Vadi wrote:
Mon Apr 30, 2018 10:43 am
That would be correct - as the first post states, you need to add triggers to teach it how to recognize rooms in your game. Give it a go, and let us know if you get stuck!
I'm having trouble right out the gate. I've got a real minimal handle on Mudlet in general right now. So I can set some basic triggers that recognize seeing a phrase in the MUD output. I don't know how to recognize based on color, I can see how that would be helpful on mapping. I know to use send("<MUD output>") for each line. I just learned a few days back to use ^ and $ to enclose phrases so they don't go off out of context. I know what triggers, aliases, buttons etc, are. I haven't really gotten a handle on variables

So It's all looking a bit foreign to me. I'm going to try to watch more intro videos on youtube, but I'm getting antsy to get going on the map. I don't understand what all the symbols mean that are in the preset trigger. What does all ^\[ ([\w\s]+) \] mean. Darkstone is set up where room names and exits are white, not much else is. The description is between them and yellow.

Exits are formatted
Exits: north ]east[ west.

the [ ] showing a closed door and a ] [ an open one.

I can find a video tutorial for downloading predone maps, but there aren't any for this MUD that I can find. So could I get some help either learning the bits I need to understand this or to walk me through a basic set up that will capture room names and exits? I can figure out doors and special issues down the road.
2018-05-08 10_11_04-Darkstone - Mudlet 3.9.0.png
Different color for the description because it is night. Default blue but my eyes always struggle to read that.

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Generic Mapping Script

Post by Jor'Mox »

Okay, so, basic strategies I can see for making the necessary triggers based on your description and the included image.

Since the room name and the exits are both the same color, and of a color that is unusual, we can filter out a lot of the junk by using a color trigger. To do this, go to the drop down menu to the right of the box for the trigger pattern, and select "color trigger". Then select the appropriate foreground and background colors. Then, we want to use code to exclude random cases of that color, differentiate between the name and the exits, and store the information appropriately. Here is some code that I believe should do that:

Code: Select all

if matches[1] == line then
     if string.starts(matches[1],"Exits:" then
         local exits = string.gsub(matches[1],"[%]%[],"")
         exits = string.match(exits,"Exits: (.*)%.)
         map.prompt.exits = exits
         raiseEvent("onNewRoom")
     else
         map.prompt.room = matches[1]
     end
 end
Then, you need a trigger to capture the presence of your prompt. In your case, it looks like it starts with a time (\d+[AP]M) followed by a space, some difficult to read number, and a square bracket (which should be enough detail to ensure that you won't accidentally capture anything). A reasonable pattern to capture this could be as follows: ^\d+[AP]M \d+\[
Note that it does NOT have a $ at the end, because I'm not bothering to have it match all the way to the end of the line. The code for this trigger is very simple, as it just needs to raise the onPrompt event and clear out previous room info. So it looks like this:

Code: Select all

raiseEvent("onPrompt")
map.prompt.room = nil
map.prompt.exits = nil

Scolius
Posts: 10
Joined: Mon Apr 30, 2018 7:24 am

Re: Generic Mapping Script

Post by Scolius »

Thank you for your quick reply. So then, if I understand, I create two triggers, copy the first into the first and the second to the second. The first trigger would then just need a name and the color changes you described.

The second one needs me to also copy in ^\d+[AP]M \d+\[
to the lines for patterns to recognize.

Does the first bit of code then replace the included "Room Name Trigger" in the basic package, or supplement it?

Also, could you help breakdown these symbols a bit? for example, does d just mean anything here is fine? The only bits I understand in it are the ^ and that it ends with a [ even though it could go on as it doesn't have a $ to cut it off.

Edit: I tried giving it a go and get this error
2018-05-08 11_52_06-Darkstone.png
2018-05-08 11_52_06-Darkstone.png (33.86 KiB) Viewed 6106 times
the error

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Generic Mapping Script

Post by Jor'Mox »

Okay, so error first. I made a typo. In the second line, right before the "then", there should be a closing parentheses to match the opening one on that line. Also, I'm missing a few closing double quotes. The fixed code follows:

Code: Select all

if matches[1] == line then
     if string.starts(matches[1],"Exits:") then
         local exits = string.gsub(matches[1],"[%]%[]","")
         exits = string.match(exits,"Exits: (.*)%.")
         map.prompt.exits = exits
         raiseEvent("onNewRoom")
     else
         map.prompt.room = matches[1]
     end
 end
Explanation of the regex pattern ^\d+[AP]M \d+\[
\d -> this matches any number 0-9
+ -> this means that whatever is immediately before it must be matched one or more times, so \d+ will match any length of numbers in a row
[AP] -> the things within the square brackets represent a set of things that can be matched in this position, in this case, an 'A' or a 'P'
M -> just an 'M'
\ -> this is the regex escape character, used because [ has a special meaning in regex, so you need to escape it so that it knows that you are looking for an actual [, rather than the [ being the beginning of a set declaration (as in [AP])

Other really common things you will see in regex patterns:
\w -> "word" characters, a-z, A-Z, 0-9, and _
\s -> white space characters, including spaces, tabs, carriage returns, etc.
\n -> new lines
. -> ANY character
* -> similar to +, only this matches 0 or more of the preceding character/set
? -> 0 or 1 of the preceding character/set
() -> marks a capture group, so that whatever is between the parentheses will be captured for later use, being stored in the matches table

Scolius
Posts: 10
Joined: Mon Apr 30, 2018 7:24 am

Re: Generic Mapping Script

Post by Scolius »

Thank you for that explanation. So the capture for triggering new rooms basically means any order of any letters/numbers and spaces. The color filter will then help so it'll only catch the white and nothing else.

I've got the fixed code swapped in, but I'm getting an error when I try to start mapping. I've tried it in a few rooms. I start with typing

start mapping Town Square

and receive

Start Mapping Error: No room detected!

I have the original room trigger still in. Does this replace it or is it in addition to? I'm guessing it is a replacement but I'm not sure. I also have the prompt trigger you made setup in another trigger, but I don't think it's an issue, it sounded pretty straightforward.

I'm not crowding up the topic am I? Should these be PM? Or a separate thread?
2018-05-08 17_22_44-Greenshot.png

Post Reply