Generic Mapping Script

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

Re: Generic Mapping Script

Post by Jor'Mox »

With a pattern like that, I would recommend a reset variable like you have for the exits, since it is possible you will see additional lines that start with a capital letter by accident. Also, I would broaden the range of possible characters to include apostrophes, hyphens, and punctuation marks, and remove the \n at the end (the $ stands in just fine for the end of line, the \n is either unnecessary or excessive).

The reason you are having trouble with the map generation itself though is most likely a mix of a couple of factors. One, in this case the room names you can capture in brief vs. verbose mode do not match, so you can't use both. You have to pick one. I understand the look thing causing some hiccups, but that can be fixed by disabling "search_on_look" configuration that can be found near the top of the script. Alternately, just always map in verbose mode. Two, any attempt at mapping will occasionally run into some problems, and they have to be corrected right away, or everything escalates out of control. As soon as you notice something is wrong, try the following: "stop mapping", figure out what it was that messed you up, and see if there is some way to fix it, walk back to whatever the last room that mapped properly was, "start mapping", delete all of the messed up rooms from the map (select them, right click and pick delete), step off in the direction of the rooms you just deleted, because the exit that led from the room you are in into the room you deleted will have been removed, and you want to restore it right away.

Intort
Posts: 15
Joined: Wed Aug 29, 2018 1:49 pm

Re: Generic Mapping Script

Post by Intort »

thanks for reply.

i have change "search_on_look" flag to false and deleted verbose pattern.
so that when looked, it becomes not causing odd behavior (go missing 1 move on mapper when 'stop mapping'. and endless duplicates on step in/out when 'start mapping').

but there was another case heads up. its same kind of problem and it even affects in brief mode as former.
and it relates to my curious question of 'capturing only 1st line'.
that is another reason why i asked.

in t2t mud, as i feared, there were many such expression of <object name>(state) in room description. some are interactive object, and others not.
which is identical to the pattern of Exits trigger. 'room name (exits directions)'
this causes same 'missing one move on mapper' problem.

so, to avoid this for mapper sake, i think its best eliminate all other matches of next or later lines.

i thought this issue has been already resolved by top 2 lines of given Exits script.
it looks once found matched, it stops searching for other lines.
but seems not working like that way.
Code: [show] | [select all] lua
if not found_exits then --this
  found_exits = false --and this

  local dirs = {n = 'north', s = 'south', w = 'west', e = 'east', d = 'down', u = 'up', ne = 'northeast', nw = 'northwest', se = 'southeast', sw = 'southwest', enter = 'in'}  

  local exits = matches[2]
  exits = exits:gsub("%a+",dirs)
  map.prompt.exits = exits
  raiseEvent("onNewRoom")
  print(map.prompt.exits)
end
so i think i need to find a way to negate other lines' matches once it got in a line anyway.

as for importance of 'stop mapping' when things went messy, i have come to find it through my experience.
im doing 'start mapping' with great care now, and making use of save, load, and backup on regular basis.

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

Re: Generic Mapping Script

Post by Jor'Mox »

Okay, I think the key will be changing the way we do the direction replacement. In doing so, we will make it so we can detect if there are real exits being detected or not, and if there aren't, we will ignore that match because it isn't really exits. Like this (using this as the trigger pattern: ^([A-Z].*)\(([\w\s,]+)\)):
Code: [show] | [select all] lua
local dirs = {n = 'north', s = 'south', w = 'west', e = 'east', d = 'down', u = 'up', ne = 'northeast', nw = 'northwest', se = 'southeast', sw = 'southwest', enter = 'in'}
local exits, found_exits
for w in matches[3]:gmatch("%a+") do
  if dirs[w] then
    found_exits = true
    if not exits then
      exits = dirs[w]
    else
      exits = exits .. " " .. dirs[w]
    end
  end
end
if found_exits then
  map.prompt.exits = exits
  map.prompt.room = matches[2]
  raiseEvent("onNewRoom")
  print(map.prompt.exits)
end
This way, it searches through what the trigger captures as exits, looking for a match in the table. If it finds a match, then we know we really have exits.

Intort
Posts: 15
Joined: Wed Aug 29, 2018 1:49 pm

Re: Generic Mapping Script

Post by Intort »

thanks for another script... but it doesn't work for some of captured special exits.
it was my fault, so i write everything what i know about exits.

examples in t2t mud (brief mode),
1st occurrence of exits are :<room name>(n, sw, e, office, bar, enter, u and out)
1) common > w, e, s, n, u, d, nw, ne, sw, se, and out are common
2) special > 'office' or 'enter' is special exit route to enter same/other room (room can hold any numbers of this type. kinda named 'In').
3) interactive > 'bar' is just in-room facility to gain access to interactive object/shop.
common and special are taken into actual move while interactive is not.

2nd is water route. follows just after 1st one.:
<room name>(w, e, and s) [nw, n and ne]
it exists in only specific room like riverside. has unique color and never overlap 1st. (i don't see exception so far anyway.)
as for 'special' or 'interactive' for water route, i don't know yet.

so, in case the room had both type of exists, it becomes like this (in single line):
<room name>(common + special and/or interactive exits) [water route]

possible cause of confusion exists just in other lines.
that's why i thought 'find matching then ignore other lines' way might be needed.

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

Re: Generic Mapping Script

Post by Jor'Mox »

Okay, so we can easily make a revised pattern to get the optional water exits, like this: ^([A-Z].+)\(([\w\s,]+)\)\s*\[?([\w\s,]*)\]?

And then we modify the script to combine both sets of captured exits before searching them, like this:
Code: [show] | [select all] lua
local dirs = {n = 'north', s = 'south', w = 'west', e = 'east', d = 'down', u = 'up', ne = 'northeast', nw = 'northwest', se = 'southeast', sw = 'southwest', enter = 'in'}
local exits, found_exits
local combined = matches[3] .. " " .. matches[4]
for w in combined:gmatch("%a+") do
  if dirs[w] then
    found_exits = true
    if not exits then
      exits = dirs[w]
    else
      exits = exits .. " " .. dirs[w]
    end
  end
end
if found_exits then
  map.prompt.exits = exits
  map.prompt.room = matches[2]
  raiseEvent("onNewRoom")
  print(map.prompt.exits)
end
Something to bear in mind is that the mapping script, while it doesn't have issues with being given special exits, can't use them to automatically make exits (though you can add such exits in a different way). So as far as the contents of map.prompt.exits goes, all that matters is the standard exit directions, including "in" and "out". For exits that require some other command to use, you would want to add these as special exits, which for the purposes of this script are considered "portals". So, if your special exit command were "office" (for example), then to add it you would use this command: add portal office

It will then send the command "office" to move you through the portal, and link the newly collected room to the previous room by way of a special exit. Visually though, the two rooms will be placed on top of each other on the map, because there is no clear direction to use when placing the new room. You can move the room around though by using the "shift" command. So if you wanted to move it north from where it is at, just type "shift n" while standing in the room you want to move. I find the shift command to be great for making minor corrections to maps, especially when it comes to making things line up in the way that I want. Also, if you accidentally produce two copies of a room, you can shift them so that they are in the same spot, and then use "merge rooms", to combine them into a single room. All together, those commands cover most of what is necessary to do mapping with this script.

Intort
Posts: 15
Joined: Wed Aug 29, 2018 1:49 pm

Re: Generic Mapping Script

Post by Intort »

i have been trying different muds to adapt to GAM.
so far, i found these actual situations when mapping.

1) working 3 basic (Room name, Exits and Prompt) triggers are least AND must condition.
with single character of mistake, mapper won't start/respond well.

2) even if condition 1 had met, some mud willingly breaks expected line layout of room info (especially when prompt line was disturbed by such as chats, mobs, pets, event texts' cut in). in that case, on going mapper will be affected and confused immediately.

3) lag can kill working GAM easily. if the target mud server was/became less responsive, consistent mapping becomes near impossible.

4) once succeeded in starting mapper, 'onMoveFail', 'onRandomMove', 'onForcedMove', and 'onVisionFail' event triggers become vital.
actually, add/editing those triggers is the primal job when using GAM.
and collecting needed strings is really time consuming. (unless user could have known them in advance)

5) any improper info AND new, unexpected irregulars break connection of the rooms. inevitably it leads to chained-duplication.
this happens quite often. user should prepare for this anytime and has to deal with it asap.


"stop mapping", 'load map local', 'start mapping', 'save map' are the commands which i use regularly.

i strongly recommend making backup of map.dat (in profile's root) and time-stamped map.data (in 'map' folder under profile).

Katerine459
Posts: 6
Joined: Mon Nov 26, 2018 9:59 pm

Re: Generic Mapping Script

Post by Katerine459 »

I apologize if this is a stupid question, but I'm something of a beginner, both to Mudlet and to Lua. I'm running 2.1 (was running 3.0.1, but then I downgraded to the official release when I was troubleshooting this problem), and trying to install this mapper for a Dikumud.

Here's what I did (step-by-step):
  • Went into scripts
  • Created a new script, and gave it the name, "DikuMapper". Left "Registered Event Handlers" and "Add User Defined Event Handler" blank.
  • Copied and pasted the entire code from the first post into the code box.
  • Clicked Save Item, and then Activate
I get the following message: Lua syntax error:[string "-------------------------------------..."]:121: attempt to index local 'string' (a nil value).
Line 121 is this line:
string.format = oldstring.format

I found a tip online that in Lua, a colon is better than a period for object property calls, so I replaced it with this code:
string:format = oldstring:format

...and get: Lua syntax error:[string "--------------------------------------..."]:121: function arguments expected near "=".

Could somebody please explain what's happening and how to fix it? Also, if there's anything else that I should be doing rather than just running the code as-is (i.e. manually filling in variable values), what should I fill in, and with what values from the text of my mud?

Many thanks!

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

Re: Generic Mapping Script

Post by Jor'Mox »

While the original version of this script works with Mudlet 2.1, the current version does not. It uses numerous changes that have been made since as part of how it functions, including the error you noticed here. Fixing this particular error would be easy, but it would just lead you down a path of having to work around all of the other changes that have been added since. At this point, I can't even say for sure what is the minimum version needed for it to work properly, but given that several changes were made specifically to address issues that arose while working with this script, I know it is somewhere beyond 3.0. It obviously works properly with the most recent version (3.15).

Darkfire
Posts: 2
Joined: Thu Jan 24, 2019 2:10 pm

Re: Generic Mapping Script

Post by Darkfire »

Hello I was wondering if anyone could help with getting the mapper to detect my room descriptions. I have been trying to get it set up for a few days and I can't seem to get the mapper to see the prompt or other items it needs.

https and then drive dot google dot com/open?id=1gjz3G_ioTYWpyhLJuJUVgviWUozkT0Sk

The link shows an image with a full room description including room exits and the prompt at the bottom.

If you would like to see the actual mud it is at dbinfinity bounceme net port 4000.

Any help or advice towards a general direction to start using the script to build maps would really help me out.

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

Re: Generic Mapping Script

Post by Jor'Mox »

So, to capture your prompt, I would do this: map prompt %(PowerLevel:<[%d%.]+b%|[%d%.]+b>%)
If the "b" part of things can change, then you can replace each of the two 'b's with %a instead, so it will match any letter.

Then, to capture the exits, I would take the Multi-Line exits trigger and modify it as follows:
Change the pattern to be: ^Obvious exits:
Change the patter of its child trigger to: ^(.*)\.
Change the code for the child trigger to: raiseEvent("onNewRoom",matches[2] or "")

Post Reply