Generic Mapping Script

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

Re: Generic Mapping Script

Post by Jor'Mox » Wed Sep 05, 2018 5:11 pm

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 » Thu Sep 06, 2018 2:44 am

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: 1069
Joined: Wed Apr 03, 2013 2:19 am

Re: Generic Mapping Script

Post by Jor'Mox » Thu Sep 06, 2018 11:34 am

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 » Thu Sep 06, 2018 3:44 pm

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: 1069
Joined: Wed Apr 03, 2013 2:19 am

Re: Generic Mapping Script

Post by Jor'Mox » Thu Sep 06, 2018 4:28 pm

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 » Mon Sep 17, 2018 1:01 am

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).

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests