Generic Mapping Script

All and any discussion and development of the Mudlet Mapper.
User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Generic Mapping Script

Post by Vadi »

Unrelated, but you can right-click "Copy to HTML" and paste to https://ada-young.appspot.com/pastebin to get it nicely formatted.

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

Re: Generic Mapping Script

Post by Jor'Mox »

freon wrote:
Tue Oct 10, 2017 11:57 am
From my understanding: The mapper needs to capture the following things:
Room name
Room Description
Exits

And I can see that there are triggers for those. Great!

I don't understand how they work *cries*

This is how the mud lays stuff out:

You begin walking southward, with a smooth and even stride.
Command is entered to move and it gives you the movement echo with a slight delay

<**** / ^^^^^ / ||||||> <-- prompt


A Cramped, Bunk-Set Male Dormitory <-- room name
Exits: north (open door) up (closed female-dorm-door) <-- multiline exit, includes 4 cardinal directions, 4 in-betweens, up, down, and I think stuff like upsouth, downsouth etc.

This dormitory has been rammed full of double bunks, leaving little room for
guards to pass through the room unhindered by traffic or room for furniture.
One such route does however wind its way around the western edge of the room
and northward where it meets a set of creaky wooden stairs leading to another
room above. In the eastern side of the room torches burn an orange glow in
their sconces, set above a series of low lockers which are latched with small
wooden doors. <-- Room desc

Guards come and go, squeezing through the narrow path between bunks.

There are several furnishings here.
A rough, linden bin is marked with a huge, crudely drawn hammer.
A rough, birch bin is marked with a stone wall design.
A rough, brownish-cream bin is marked with a sword design.
A rough, linden bin sits here.
A rough, crabapple bin has been tucked under a bunk-bed with brown coarse
wool sheets.
A rough, beech bin sits here.
A patrolling guardsman keeps a watchful eye on the entryways here.

<**** / ^^^^^ / ||||| >

The way the prompt works:
<****** <-- the *s represent health from 0 asterisks to 6
^^^^^^ <-- the ^s represent trauma from 0 chevrons to 6
|||||| <-- the |s represent stamina from 0 horizontal lines to 6

walking, fighting, getting hurt, falling, etc reduce these, as you can see in the output, I'm down to 4 stars of health.

I was thinking of manually creating the rooms instead of having them automatically done, and then creating aliases to move and travel through the rooms, but I can't quite create the rooms, try as I might. :cry:
Okay, so time for me to get a bit more info. Is the room name always IMMEDIATELY BEFORE the exits line? If so, that should make it very easy to capture reliably. Multi-line exit info can take a bit more work, and even more so given how what you are getting clearly needs to be cleaned up, but nothing overly complicated. If there are these "down-south" exits that you mentioned, that will get extra tricky, because neither Mudlet's Mapper nor my script currently have support for exits in those directions. Something could be cobbled together to make it work, but that part will take more time than everything else combined, FYI. The directions supported currently are the cardinal directions (n,s,e,w), the ordinal directions (nw, sw, ne, se), up, down, in, and out. As well as special exits that are treated as portals.

To grab that prompt, I would use this regex pattern: ^\<\s*\**\s*\/\s*\^*\s*\/\s*\|*\s*\>

Room descriptions don't need to be captured.

freon
Posts: 13
Joined: Sun Oct 01, 2017 5:18 am

Re: Generic Mapping Script

Post by freon »

There's usually a delay of a few seconds after the movement command is put in and the movement echo is given. In that time, stuff can happen, like other characters walking into the room or performing other actions.

The room name is always served immediately before Exits:, though.

Exits are a bit predictable in the order that they are shown and the upsouth downsouth etc exits don't really happen very often.

freon
Posts: 13
Joined: Sun Oct 01, 2017 5:18 am

Re: Generic Mapping Script

Post by freon »

Occasionally there is a line between the room name and the exits but that's rare.

exits go in this order: NESW UD NENWSESW

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

Re: Generic Mapping Script

Post by Jor'Mox »

freon wrote:
Wed Oct 11, 2017 1:58 pm
Occasionally there is a line between the room name and the exits but that's rare.

exits go in this order: NESW UD NENWSESW
The order of exits doesn't matter, so don't worry about that part. The line between room name and exits, is it a blank line, or can it have content?

freon
Posts: 13
Joined: Sun Oct 01, 2017 5:18 am

Re: Generic Mapping Script

Post by freon »

It's blank and will not have content or anything there.

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

Re: Generic Mapping Script

Post by Jor'Mox »

Okay, can you post an example of the multi-line exits please? I need to make sure I can capture all the right things when designing the triggers for this.

freon
Posts: 13
Joined: Sun Oct 01, 2017 5:18 am

Re: Generic Mapping Script

Post by freon »

If there are doors on many of the exits, the lines can get pretty long:

Outer Courtyard and Training Yard of the Guardhouse
Exits: north (open infirmary-door) east (closed door) south
(closed door) west (open large-heavy-door)

When there are many exits, the line breaks:

At a Thick, Knotted Wall of Twisted Trees to the North
Exits: east south west northeast northwest
southeast southwest

Note: first line is the room name.

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

Re: Generic Mapping Script

Post by Jor'Mox »

Okay, so I put together two triggers that should work to get things rolling for you. The first is going to handle capturing the room name and exits, while the second will be the prompt trigger.

The first trigger has two patterns, in the following order (both of type perl regex):
Pattern 1: ^Exits: (.*)$
Pattern 2: ^(.*)$

And it has this code:
Code: [show] | [select all] lua
if matches[1] == matches[2] then
    map.prompt.found_exits = true
    map.prompt.found_room = true
    map.prompt.exits = matches[2]
elseif map.prompt.found_exits then
    if not string.match(matches[2],"^%s*$") then
        map.prompt.exits = map.prompt.exits .. " " .. matches[2]
    else
        map.prompt.exits = string.gsub(map.prompt.exits,"%([^%)]*%)","")
        map.prompt.found_exits = false
        raiseEvent("onNewRoom")
    end
elseif not map.prompt.found_room and not string.match(matches[2],"^%s*$") then
    map.prompt.room = matches[2]
end
The prompt trigger will have the pattern I gave you previously for it, and will have the following code:
Code: [show] | [select all] lua
map.prompt.found_room = false
raiseEvent("onPrompt")

freon
Posts: 13
Joined: Sun Oct 01, 2017 5:18 am

Re: Generic Mapping Script

Post by freon »

Thank you so much! I'll give these a try.

Post Reply