Difference between revisions of "Generic Mapper Additions"

From Mudlet
Jump to navigation Jump to search
m (added some comments to code to better explain why those checks were specifically added)
Line 329: Line 329:
 
</syntaxhighlight>It also adds the ability to save doornames for doors, and changes the speedwalk mapper function to use doornames and modifies the door open/unlock string to match the command syntax expected for this server.  (ie <code>open <doorname> <direction></code>)
 
</syntaxhighlight>It also adds the ability to save doornames for doors, and changes the speedwalk mapper function to use doornames and modifies the door open/unlock string to match the command syntax expected for this server.  (ie <code>open <doorname> <direction></code>)
  
==== '''Triggers:''' ====
+
==== Triggers: ====
 
In the generic_mapper trigger group, disable all language groups
 
In the generic_mapper trigger group, disable all language groups
  

Revision as of 19:59, 28 May 2022

This is a collection of triggers for the generic mapper script that are too dangerous to be enabled for all games and should only be added on a per-game basis. Eventually we'd like to add the to the generic mapper script when it's able to enable patterns on a per-game basis.

Ashes to Ashes/Alternate Illusions

timetoplaythegame.com:3333

This is for muds with multiline exits similar below:

Temple of Midgaard
   You are in the southern end of the temple hall in the Temple of Midgaard.
The temple has been constructed from giant marble blocks, eternal in
appearance, and most of the walls are covered by ancient wall paintings
picturing Gods, Giants and peasants.
   Large steps lead down through the grand temple gate, descending the huge
mound upon which the temple is built and ends on the temple square below.
To the west, you see the Reading Room.  The donation room is in a small
alcove to your east.
An automatic teller machine has been installed in the wall here.
An announcement board is mounted on the wall here.
Obvious exits:
North - By the Temple Altar
East  - Midgaard Donation Room
South - The Temple Square
West  - The Reading Room
Down  - The ABC's of Ashes to Ashes

Astana 498/498hp 1105/1105m 139/139v 0xp 0%>

Here are the steps:

  • On the generic_mapper -> English Trigger Group, disable the English Exits Trigger
  • There's a disabled English Multi-Line Exits Trigger under the same folder. Copy and paste it outside the generic_mapper folder.
  • Change the trigger filter regex of English Multi-Line Exits Trigger to ^Obvious exits:
  • On the next item Exit Line Trigger, change the regex to ^([\w\s]+)\s*\-\s[\w ']+
  • We want to raise an event of onNewRoom when we're done capturing all the room exits:
    • add a new item after Exit Line Trigger and add a regex filter ^$
    • put the call raiseEvent("onNewRoom",matches[2] or "") on the new item

Avatar Mud

avatar.outland.org:3000

Create a new script called SetGMCPRoomName

Add User Event Handler: gmcp.Room.Info

function setGMCPRoomName() -- MUST match the 'name' above
  -- if map.getRoomAreaName ~= gmcp.Room.Info.zone then
    -- map.set_area(gmcp.Room.Info.zone)
  -- end
  map.prompt.room = gmcp.Room.Info.name
  map.prompt.exits = table.concat(table.keys(gmcp.Room.Info.exits), " ")
  raiseEvent("onNewRoom",map.prompt.exits)
end

That's it :) map away! Will update if any more things need to be tweaked - Added by Whiteheat - 9 April 2021

Kingdoms of the Lost

kotl.org: 2222

exit lines:

[inside: south->closed]

[field: north->closed *east *south->open west]

[field: *east west]

[city(very bright): north east south west up northwest]

regex for the above: \[.+: (.+)\] (regex101)

Reinos de Leyenda

map translate north norte n
map translate south sur s
map translate east este e
map translate west oeste w
map translate northwest noroeste no
map translate northeast noreste ne
map translate southwest suroeste so
map translate southeast sureste se
map translate up arriba ar
map translate down abajo ab
map translate out fuera fu
map translate in dentro de

-- ensure normal prompt is setup in the game that matches this exactly, include the space in the end of the pattern:
map prompt ^PV: %d+/%d+ GP: %d+/%d+;

Aladon

Make a new trigger with this perl regex pattern:

^\s*\[\s*Видимые выходы:\s*(.*)\]

that does this:

raiseEvent("onNewRoom",matches[2] or "")

Then enter the following in the input line:

map translate north север с
map translate south юг ю
map translate east восток в
map translate west запад з
map translate up вверх вв
map translate down вниз вн

That's it! Now you can do start mapping my first area.

Federation2

play.federation2.com: 30003

Add this pattern to Triggers->generic_Mapper->English Trigger Group->English Exit Triggers

[Ee]xits:\s(.*)

Define the prompt byː

map prompt You can see %.+ exits:


Now you can do start mapping my first area.


Brutália

telnetbrutalia2.avantek.hu 4444

Make a new trigger, with this perl regex pattern:

^.+kijáratot látsz: (.*)\.$

That does this:

raiseEvent("onNewRoom",matches[2] or "")

Then add another trigger perl regex pattern:

Nem mehetsz abba az iranyba.

That does this:

raiseEvent("onMoveFail")

Then, enter the following to the input line:

map translate north észak e
map translate south dél d
map translate east kelet k
map translate west nyugat n
map translate northwest északnyugat en
map translate northeast északkelet ek
map translate southwest délnyugat dn
map translate southeast délkelet dk
map translate up fel fe
map translate down le le
map translate out ki ki 
map translate in be be

Now you can do start mapping my first area.

MysticalMud

mysticalmud.org:5000

Add this pattern to Triggers->generic_Mapper->English Trigger Group->English Exit Triggers

^\[Exits:\s*(.*)\]

and add to the LUA code ABOVE the existing line: if (matches[2]) then matches[2] = matches[2]:gsub("."," %0"):sub(2) end

Now you can do start mapping my first area.

RetroMUD

retromud.org:3000

Disable the in-game line wrapping and let Mudlet do it for you instead - this'll help the mapper recognize exits that span over the course of two lines. You can do it with the in-game command: set WIDTH 150

This breaks formatting on some menus like show skills, set it back when needed.

You should also setup some patterns to ignore to make sure the mapper doesn't get confused when you're not actually moving:

map ignore .+ follows .+
map ignore .+ starts using .+
map ignore .+ arrives from .+
map ignore .+ images of .+

If the game fails to capture room names because you get enviroment/flavor/etc lines after move command and before room name you can create a color trigger to capture them.

Start by setting the color ingame with color roomshort <color>, it can be any color as long as it's used only for this and doesn't match any other color *exactly*. To see the list of colors ingame type color display.

Next create a new trigger, room name.

  • Set it to color trigger and match foreground color with the one you chose ingame.
  • Paste map.prompt.room = matches[1] in the Lua code field.

The Two Towers

Host: t2tmud.org:9999

Regex pattern for English Exits Trigger: ^(\X+)\(([\w\s,]+)\)\s*\[?([\w\s,]*)\]?

Lua code for trigger - FYI, the RGB colors are to help with room name detection. For the ones shown, I have the color for my room_shorts set to bright yellow. In the code below, you'll notice I excluded the room "Near a guard flet." That's because this room is inserted randomly at intervals into the Lothlorien area. I set the room names for all rooms that were shown as either Lothlorien or Near a guard flet to "Lothlorien" and then adjusted these triggers to account for them changing names.


Also, add ^Near a guard flet -- regex -- to the English Vision Fail Trigger.

local dirs = {n = 'north', s = 'south', w = 'west', e = 'east', d = 'down', u = 'up', ne = 'northeast', nw = 'northwest', se = 'southeast', sw = 'southwest', enter = 'enter', out = 'out'}
local exits, found_exits
local combined = matches[3]

selectCurrentLine()
local r,g,b = getFgColor() 
if r == 255 and g == 255 and b == 0 then
    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
           
        else 
            found_exits=true
            if not exits then
                exits = w
            else
                exits = exits .. " " .. w
            end
        end
  end

  if found_exits and matches[2] ~= "Near a guard flet" then
          map.prompt.exits = exits
          map.prompt.room = matches[2]
          cecho(matches[2])
          raiseEvent("onNewRoom")
          print(map.prompt.exits)
  end
end

You can create a trigger using the same regex pattern as above to show you the rgb values for whatever color you have your room_short set to.

selectCurrentLine()
local r,g,b = getFgColor()
cecho("\nred " ..r.. " green " ..g.. " blue "..b)
deselect()

3 Kingdoms / 3 Scapes

3k.org 3000 / 3200

You can create a color trigger to capture room name and exits.

First choose the color ingame with setcolor room_short <color>, it can be any color as long as it's used only for this and doesn't match any other color *exactly*. To see the list of colors ingame type ansi colors.

Next disable English Exits Trigger under generic_mapper > English Trigger Group

Next create a new trigger group and add two items to it, room name and room exits.

  • room name
    • choose color trigger and set foreground color to the one you set ingame
    • paste
map.prompt.room = matches[1]

in the Lua code field.

You will have to create one for exits as well since sometimes they span over multiple lines and fail to get captured.

  • room exits
    • choose color trigger and set foreground color to the same color as room name
    • paste
mystring = matches[1]
map.prompt.exits = mystring:gsub([[.+%((.+)%).+]], "%1")

in the Lua code field.

You will have to add a bunch of triggers to English Failed Move Trigger under generic_mapper > English Trigger Group as well.

.+ only .+ may go in there.$
^You must be .+ to (?:pass|enter).*$
.+ won't let you go .*.$
^You can't head .*.$
^Sorry, but you must be .*.$
^You bump into the .+ (?:door|gate).$
^You are too .+ to (?:enter|pass).*.$
^A locked .* blocks your passage .*.$
^You jump back .*.$
.+ you .+ come back.$

There's probably a lot more...

Realm of Magic

realmofmagic.org:4000

This is for muds that look like below:

RealmofMagic Room display.png
A Peaceful Inn [ D ]
  The inn seems to be strong and finely built with many plaques and tapestries
adorning the walls. On either side of the inn there are very large delicately
crafted glass windows that look out onto the rest of Entrancity. You see a
dark, cherry wood desk sitting near the back of the northern wall. The desk is
cluttered with paperwork and many different types of writing tools.
There is a sign on top of the desk written in gold that should be 'read'.
There is a book with QUESTS on the cover, you should read the quests book.
An automatic teller machine has been installed in the wall here.
Anthony the wise is sitting at a table.
His eyes shine in a soft blue!
Janet the Innkeep is leaning on the front desk.
|572H 625M 582V >

It also adds the ability to save doornames for doors, and changes the speedwalk mapper function to use doornames and modifies the door open/unlock string to match the command syntax expected for this server. (ie open <doorname> <direction>)

Triggers:

In the generic_mapper trigger group, disable all language groups

Create a new trigger group for your mapping triggers (so they don't get deleted on generic_mapper package updates), and create the following (numbered) triggers:

  1. Trigger has two patterns. The first is a color pattern with the foreground color being ANSI 6 (Cyan). The second pattern is Regex: ^(.*?) (?:\(#\d+\) )?(?:\[ .*? ?\] )?\[ ?((?:\(?[NESWUD]\)?\s?)*)\] ?(?:Home: \d+)?$ This should match for both mortals and immortals. The script for this trigger:
    if not map.prompt.name_found then
      map.prompt.name_found = true
      map.prompt.room = multimatches[2][2]
      map.prompt.exits = string.gsub(multimatches[2][3], "%(%a%)%s?", "") --remove doors so unmapped playerhomes or unmapped doors don't mess up the map/following when immortal
    end
  2. Trigger is just a regex match: ^\|(-?)(\d+)H (\d+)M (\d+)V (.*)>$ with the script:
    raiseEvent("onPrompt")
    if map.prompt.name_found then
      map.prompt.name_found = false
      --The onPrompt event called above raises "onNewRoom" when exits are found. 
      --The following block will catch the infrequent rooms found with no listed exits.
      if map.prompt.exits == "" then
        raiseEvent("onNewRoom")
      end
      --Whem onRandomMove event wasn't following reliably, the below block was created to force 
      --the map to reorient its position after certain actions (entering portals, fleeing from combat, etc).
      if map.prompt.user_portaled then
        map.prompt.user_portaled = nil
        map.find_me()
      end
    end
  3. Trigger that matches the following lines and throws the onMoveFail event:
    1. Start of Line: As you step on something very slippery, you lose your
    2. Regex: ^(.*) seems to be closed.$
    3. Exact Match: Maybe you should get on your feet first?
    4. Exact Match: Alas, you cannot go that way...
    5. Exact Match: You would have to fly to go there!
    6. Exact Match: You need a boat or be able to swim to go there.
    7. Exact Match: That place is already full!
    8. Exact Match: No way!  You're fighting for your life!
    9. Regex: ^There is no (.*) here.$
      raiseEvent("onMoveFail")
  4. Trigger that exact matches: It is pitch black... and throws the onVisionFail event:
    raiseEvent("onVisionFail")
  5. Trigger that exact matches the following lines and scripted to set the map.prompt.user_portaled variable. (tried to use the onRandomMove event, but it wasn't as reliable)
    1. You enter the portal.
    2. You flee head over heels.
    3. You skillfully retreat from battle.
      map.prompt.user_portaled = true

Aliases:

Next, create an alias. Pattern is: ^add doorname (\w+) (north|south|east|west|up|down|n|s|e|w|u|d)$ and the script is:

map.add_doorName(matches[2], matches[3])

Scripts:

Create a new script to add new mapping functions with the following code:

function map.add_doorName(name, dir)
  if map.mapping then
    name = name or ""
    dir = dir or ""
    if (name == "") or (dir == "") then return end
    local exits = {
      north = "north", south = "south", east = "east", 
      west = "west", up = "up", down = "down",
      n = "north", s = "south", e = "east",
      w = "west", u = "up", d = "down" }
    dir = string.lower(dir)
    if not exits[dir] then return end
  
    local dataKey = "doorname_"..exits[dir]
    name = string.lower(name)
    if name == "door" then
      clearRoomUserDataItem(map.currentRoom, dataKey)
    else
      setRoomUserData(map.currentRoom, dataKey, name)
    end
    map.echo("Added "..name.." as a doorname for "..dataKey.." in roomID: "..map.currentRoom)
  else
    map.echo("Not mapping",false,true)
  end
end

function map.get_doorName(roomID, dir)
  local doorkey = "doorname_"..dir
  local doorname = getRoomUserData(roomID, doorkey)
  if doorname == "" then doorname = "door" end
  
  return doorname           
end

In generic_mapper>Map Script, edit the following if code block at the listed lines to make use of the door names/change the unlock/open syntax to match the mud's command syntax.

           if status and status > 1 then
                local doorname = map.get_doorName(id, (exitmap[dir] or dir))
                -- if locked, unlock door
                if status == 3 then
                    table.insert(walkPath,k,id)
                    table.insert(walkDirs,k,"unlock " .. doorname .. " " .. (exitmap[dir] or dir))
                    k = k + 1
                end
                -- if closed, open door
                table.insert(walkPath,k,id)
                table.insert(walkDirs,k,"open " .. doorname .. " " .. (exitmap[dir] or dir))
                k = k + 1
            end

Usage:

As you're mapping, if you come across a door that's not named "door" (ie "gate" or "trapdoor" or even "doors"), use the command add doorname <name> <direction> to add that data to the map's roomUserData. When speedwalking with the map, the script will use this name to unlock locked doors, and open doors. You don't need to add doors named "door" because the mapper will default to using that name if no name was added with the command. This command must be used on both "sides" of the door, as each side can contain different doornames.