Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Two Towers Mapper modified for SWmud

Two Towers Mapper modified for SWmud

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  3  4  

Posted by Clafoutis   (29 posts)  Bio
Date Thu 07 Nov 2019 06:38 PM (UTC)

Amended on Thu 07 Nov 2019 07:09 PM (UTC) by Clafoutis

Message
I'm working on getting a mapper set up for SWmud.

I decided to start with the example for Two Towers from this thread, based on similarities, such as not having easily accessible rooms names, etc:

http://gammon.com.au/forum/?id=10536

The first thing I did was edit the main trigger to match SWmud.

Twin Towers code:

match="^\s{4}(?P<roomdesc>.*\n(\S.*\n)*)\s{4}The only obvious exit(s are| is) (?P<exits>.*)\.\Z"


SWmud code:

match="^(?P<roomdesc>\S.*\n(.*\n)*)(The only|There are .*) obvious exit(s:| is) (?P<exits>.*)\.\Z"


Here's an example SWmud room:

This is the transport facility, where the shuttles land. Since there are so many new destinations added to the shuttle network,
all privately owned vessels have been directed to the Main Dock to the east.  The local ship merchant, Barloke, has a dock to the west.
 
The noise here is almost unbearable.  Large passenger shuttles are constantly landing and taking off from this area.

There are three obvious exits: north, east, and west.

Dabear's Cabbie


So, right off, there's a couple of differences I tried to account for. Unlike Two Towers, room descriptions don't have 4 spaces to uniquely identify a chunk
of text from non-room descriptions. Also, sometimes you wind up with blank lines in the middle of the room description.

After playing around with modifying the match code a bit, I managed to get the mapper working... sort of. While it would map rooms, SWmud's lack of
unique room desc identifiers means I'd pick up all kinds of other stuff, which would in turn confuse the mapper into thinking a given room was multiple
rooms based on which direction I entered from.

Hmm. Perhaps there's a better way, but I experimented with putting the mapper trigger in a group along with a new trigger that would turn off the group
after it received the "exits" output. I then created a set of aliases that would tell the script engine to turn on the triggers and then execute the movement.

For example, I'd input a direction and would get something like:


Mapper_Triggers enabled
n
You climb the stairs back to the lobby.
The lobby of the Hall of Fame is a huge circular room which dwarfs even the tallest of Wookiees. An intricate pattern of stained glass fills
the ceiling above you and a polished marble floor lies underfoot. The Great Hall lies to the south, while a bar is located to the east for
those wishing to relax a bit during their visit to the Hall of Fame.
 
The smell of freshly-mixed drinks drifts in from the east.

Music from across the Star Wars galaxy is being piped in over the intercom.

There are three obvious exits: south, north, and east.
Mapper_Triggers disabled
Mapper adding room D2F16F90, name: You climb the stairs back to the lobby

An important-looking sign is here.

587/587 3 802144 8485 off undrugged > 
Mapper_Triggers enabled
n
You are standing on the eastern end of Senate Blvd.  To the east, you are amazed just how tall the Medical Facility of Imperial City is.
To the north is the Recruitment Center to enlist in the army or navy, and to the south is the glorious Hall of Fame, which houses likenesses
of all of the respected heroes and villains of the Empire.
 
There are four obvious exits: south, north, east, and west.
Mapper_Triggers disabled
Mapper adding room DC6DC520, name: There are three obvious exits: south, north, and east


As you can see, somewhere I've muffed up and in the 2nd room, it's grabbing the exits from the prior room and using it as the name for the 2nd room.
(I think)

post with full code to follow (when I can post again in 22 minutes)
Top

Posted by Clafoutis   (29 posts)  Bio
Date Reply #1 on Thu 07 Nov 2019 07:13 PM (UTC)
Message
note, I only set up a set of aliases for n, s, e, and w; I figured I'd set the others up once I had the basics working.

Part 1


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="Two_Towers_Mapper_modified"
   author="original: Nick Gammon, modifications: Merritt"
   id="565a2ddd934aca9913894ad4"
   language="Lua"
   purpose="Mapper for SWmud"
   save_state="y"
   date_written="2010-08-30"
   requires="4.51"
   version="1.1"
   >

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   enabled="n"
   lines_to_match="10"
   group="Mapper_Triggers"
   keep_evaluating="y"
   match="^(?P&lt;roomdesc&gt;\S.*\n(.*\n)*)(The only|There are .*) obvious exit(s:| is) (?P&lt;exits&gt;.*)\.\Z"
   multi_line="y"
   regexp="y"
   script="process_room_description"
   sequence="100"
  >
    </trigger>
  <trigger
   enabled="n"
   group="Mapper_Triggers"
   keep_evaluating="y"
   match="(The only|There are .*) obvious exit(s:| is)"
   regexp="y"
   send_to="12"
   sequence="200"
  >
  <send>
  EnableTriggerGroup ("Mapper_Triggers", false)
  Note ("Mapper_Triggers disabled")
    </send>
    </trigger>
</triggers>

<aliases>
  <alias
   match="^mapper find ([\w* %d/&quot;]+)$"
   enabled="y"
   sequence="100"
   script="map_find"
   regexp="y"
  >
    </alias>
  <alias
  match="^n$"
  enabled="y"
  send_to="12"
  sequence="100"
  regexp="y"
  >
  <send>
  EnableTriggerGroup ("Mapper_Triggers", true)
  Note ("Mapper_Triggers enabled")
  Send("n")
    </send>
    </alias>	
  <alias
  match="^s$"
  enabled="y"
  send_to="12"
  sequence="100"
  regexp="y"
  >
  <send>
  EnableTriggerGroup ("Mapper_Triggers", true)
  Note ("Mapper_Triggers enabled")
  Send("s")
    </send>
    </alias>	
  <alias
  match="^e$"
  enabled="y"
  send_to="12"
  sequence="100"
  regexp="y"
  >
  <send>
  EnableTriggerGroup ("Mapper_Triggers", true)
  Note ("Mapper_Triggers enabled")
  Send("e")
    </send>
    </alias>	
  <alias
  match="^w$"
  enabled="y"
  send_to="12"
  sequence="100"
  regexp="y"
  >
  <send>
  EnableTriggerGroup ("Mapper_Triggers", true)
  Note ("Mapper_Triggers enabled")
  Send("w")
    </send>	
    </alias>  
</aliases>
  

<!--  Script  -->


<script>
<![CDATA[

local MAX_NAME_LENGTH = 60
local MUD_NAME = "SWmud"

require "mapper"
require "serialize"
require "copytable"
require "commas"
  
default_config = {
  -- assorted colours
  BACKGROUND_COLOUR       = { name = "Background",        colour =  ColourNameToRGB "lightseagreen", },
  ROOM_COLOUR             = { name = "Room",              colour =  ColourNameToRGB "cyan", },
  EXIT_COLOUR             = { name = "Exit",              colour =  ColourNameToRGB "darkgreen", },
  EXIT_COLOUR_UP_DOWN     = { name = "Exit up/down",      colour =  ColourNameToRGB "darkmagenta", },
  EXIT_COLOUR_IN_OUT      = { name = "Exit in/out",       colour =  ColourNameToRGB "#3775E8", },
  OUR_ROOM_COLOUR         = { name = "Our room",          colour =  ColourNameToRGB "black", },
  UNKNOWN_ROOM_COLOUR     = { name = "Unknown room",      colour =  ColourNameToRGB "#00CACA", },
  DIFFERENT_AREA_COLOUR   = { name = "Another area",      colour =  ColourNameToRGB "#009393", },
  MAPPER_NOTE_COLOUR      = { name = "Messages",          colour =  ColourNameToRGB "lightgreen" },
  
  ROOM_NAME_TEXT          = { name = "Room name text",    colour = ColourNameToRGB "#BEF3F1", },
  ROOM_NAME_FILL          = { name = "Room name fill",    colour = ColourNameToRGB "#105653", },
  ROOM_NAME_BORDER        = { name = "Room name box",     colour = ColourNameToRGB "black", },
  
  AREA_NAME_TEXT          = { name = "Area name text",    colour = ColourNameToRGB "#BEF3F1",},
  AREA_NAME_FILL          = { name = "Area name fill",    colour = ColourNameToRGB "#105653", },   
  AREA_NAME_BORDER        = { name = "Area name box",     colour = ColourNameToRGB "black", },
               
  FONT = { name =  get_preferred_font {"Dina",  "Lucida Console",  "Fixedsys", "Courier", "Sylfaen",} ,
           size = 8
         } ,
         
  -- size of map window
  WINDOW = { width = 400, height = 400 },
  
  -- how far from where we are standing to draw (rooms)
  SCAN = { depth = 30 },
  
  -- speedwalk delay
  DELAY = { time = 0.3 },
  
  -- how many seconds to show "recent visit" lines (default 3 minutes)
  LAST_VISIT_TIME = { time = 60 * 3 },  
  
  }
  
rooms = {}

valid_direction = {
  n = "n",
  s = "s",
  e = "e",
  w = "w",
  u = "u",
  d = "d",
  ne = "ne",
  sw = "sw",
  nw = "nw",
  se = "se",
  north = "n",
  south = "s",
  east = "e",
  west = "w",
  up = "u",
  down = "d",
  northeast = "ne",
  northwest = "nw",
  southeast = "se",
  southwest = "sw",
  ['in'] = "in",
  out = "out",
  }  -- end of valid_direction
Top

Posted by Clafoutis   (29 posts)  Bio
Date Reply #2 on Thu 07 Nov 2019 08:19 PM (UTC)
Message
Part 2


-- -----------------------------------------------------------------
-- We have a room name and room exits
-- -----------------------------------------------------------------

function process_room_description (name, line, wildcards)

  local exits_str = trim (wildcards.exits)
  local roomdesc = trim (wildcards.roomdesc)
  
  -- ColourNote ("white", "blue", "exits: " .. exits_str)  -- debug
  
  -- generate a "room ID" by hashing the room description and exits
  uid = utils.tohex (utils.md5 (roomdesc .. exits_str))
  uid = uid:sub (1, 25)  

  -- break up exits into individual directions
  exits = {}
  
  for exit in string.gmatch (exits_str, "%w+") do
    local ex = valid_direction [exit]
    if ex then
      exits [ex] = "0"  -- don't know where it goes yet
    end -- if
  end -- for
  
  local name = string.match (roomdesc, "^(.-)[.\n]")
  
  if #name > MAX_NAME_LENGTH then
    name = name:sub (1, MAX_NAME_LENGTH - 3) .. "..."
  end -- if too long
  
  -- add to table if not known
  if not rooms [uid] then
    ColourNote ("cyan", "", "Mapper adding room " .. uid:sub (1, 8) .. ", name: " .. name)
    rooms [uid] = { name = name, desc = roomdesc, exits = exits, area = MUD_NAME }
  end -- if

  -- save so we know current room later on  
  current_room = uid
  
  -- call mapper to draw this rom
  mapper.draw (uid)

  -- try to work out where previous room's exit led  
  if expected_exit == "0" and from_room then
    fix_up_exit ()
  end -- exit was wrong
    
end -- Name_Or_Exits


-- -----------------------------------------------------------------
-- mapper 'get_room' callback - it wants to know about room uid
-- -----------------------------------------------------------------

function get_room (uid)
  
  if not rooms [uid] then 
   return nil
  end -- if
 
  local room = copytable.deep (rooms [uid])
 
  local texits = {}
  for dir in pairs (room.exits) do
    table.insert (texits, dir)
  end -- for
  table.sort (texits)
  
  room.hovermessage = string.format (
       "%s\tExits: %s\nRoom: %s",
        room.name or "unknown", 
        table.concat (texits, ", "),
      uid
      )
      
  if uid == current_room then
    room.bordercolour = config.OUR_ROOM_COLOUR.colour
    room.borderpenwidth = 2
  end -- not in this area
      
  return room
  
end -- get_room

-- -----------------------------------------------------------------
-- We have changed rooms - work out where the previous room led to 
-- -----------------------------------------------------------------

function fix_up_exit ()

  -- where we were before
  local room = rooms [from_room]
  
  -- leads to here
  room.exits [last_direction_moved] = current_room
    
  -- clear for next time
  last_direction_moved = nil
  from_room = nil
  
end -- fix_up_exit

-- -----------------------------------------------------------------
-- try to detect when we send a movement command
-- -----------------------------------------------------------------

function OnPluginSent (sText)
  if valid_direction [sText] then
    last_direction_moved = valid_direction [sText]
    -- print ("Just moved", last_direction_moved)
    if current_room and rooms [current_room] then
      expected_exit = rooms [current_room].exits [last_direction_moved]
      if expected_exit then
        from_room = current_room
      end -- if
    -- print ("expected exit for this direction is to room", expected_exit)
    end -- if
  end -- if 
end -- function

-- -----------------------------------------------------------------
-- Plugin Install
-- -----------------------------------------------------------------

function OnPluginInstall ()
  
  config = {}  -- in case not found

  -- get saved configuration
  assert (loadstring (GetVariable ("config") or "")) ()

  -- allow for additions to config
  for k, v in pairs (default_config) do
    config [k] = config [k] or v
  end -- for
    
  -- and rooms
  assert (loadstring (GetVariable ("rooms") or "")) ()
  
  -- initialize mapper
  
  mapper.init { config = config, get_room = get_room  } 
  mapper.mapprint (string.format ("MUSHclient mapper installed, version %0.1f", mapper.VERSION))

end -- OnPluginInstall

-- -----------------------------------------------------------------
-- Plugin Save State
-- -----------------------------------------------------------------

function OnPluginSaveState ()
  mapper.save_state ()
  SetVariable ("config", "config = " .. serialize.save_simple (config))
  SetVariable ("rooms", "rooms = " .. serialize.save_simple (rooms))
end -- OnPluginSaveState

-- -----------------------------------------------------------------
-- Plugin just connected to world
-- -----------------------------------------------------------------

function OnPluginConnect ()
  from_room = nil
  last_direction_moved = nil
end -- OnPluginConnect
  
-- -----------------------------------------------------------------
-- Find a room
-- -----------------------------------------------------------------

function map_find (name, line, wildcards)
 
  local room_ids = {}
  local count = 0
  local wanted = (wildcards [1]):lower ()

  -- scan all rooms looking for a simple match  
  for k, v in pairs (rooms) do
     local desc = v.desc:lower ()
     if string.find (desc, wanted, 1, true) then
       room_ids [k] = true
       count = count + 1
     end -- if
  end   -- finding room
  
  -- see if nearby
  mapper.find (
    function (uid) 
      local room = room_ids [uid] 
      if room then
        room_ids [uid] = nil
      end -- if
      return room, next (room_ids) == nil
    end,  -- function
    show_vnums,  -- show vnum?
    count,      -- how many to expect
    false       -- don't auto-walk
    )
  
end -- map_find


]]>
</script>


</muclient>
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Fri 08 Nov 2019 07:26 AM (UTC)
Message
I can't see anything obvious, but what I usually do with timing or sequence-related problems is to add in more debugging.

For a start, turn on Game -> Trace, and see what triggers are firing and in what order.

Then if that doesn't help add some debugging prints into your functions.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Clafoutis   (29 posts)  Bio
Date Reply #4 on Fri 08 Nov 2019 03:30 PM (UTC)

Amended on Fri 08 Nov 2019 03:42 PM (UTC) by Clafoutis

Message
turned on trace and got:


TRACE: Matched alias "^n$"
Mapper_Triggers enabled
TRACE: Executing Plugin Two_Towers_Mapper_modified script "OnPluginSent"
n
Welcome to the new Down on the Upside Cafe. Looking around in the dim room you find comfy couches together in pairs to promote discussion and
togetherness.  Small glass tables rest nearby for those hot drinks you can order from the waitress who undoubtedly must also be a struggling
artist. A rolling fire near the south end is surrounded by a few large pillows and a few good books on the mantle. The western wall has a small
stage with a microphone and chair for poets, musicians and storytellers to entertain and enlighten the crowd. A large board has a 'list' of
items on it for you to order. There is a door to the south, which seems to lead back to the street. There is also a stairwell going down, which
Jennette only allows certain people access to.
 You may also use the bulletin board here to post stories, jokes, and anything of artistic value for others to read.
 
Soft music of some foreign origin plays over the speakers.

There are two obvious exits: south and down.
TRACE: Matched trigger "^(?P<roomdesc>\S.*\n(.*\n)*)(The only|There are .*) obvious exit(s:| is) (?P<exits>.*)\.\Z"
TRACE: Matched trigger "(The only|There are .*) obvious exit(s:| is)"
Mapper_Triggers disabled
TRACE: Executing trigger script "process_room_description"
Mapper adding room 402F7BAE, name: togetherness

Jennette

* Expression Board * is here.

587/587 3 822392 3725 off undrugged > 
TRACE: Matched alias "^s$"
Mapper_Triggers enabled
TRACE: Executing Plugin Two_Towers_Mapper_modified script "OnPluginSent"
s
You are standing on the eastern side of Senate Blvd.  To the east, you can catch a better glimpse of the Medical Facilities of Imperial City.
Also, from this area, is a Coffee House to the north, and the Imperial Complex to the south.
 
There are four obvious exits: south, north, east, and west.
TRACE: Matched trigger "^(?P<roomdesc>\S.*\n(.*\n)*)(The only|There are .*) obvious exit(s:| is) (?P<exits>.*)\.\Z"
TRACE: Matched trigger "(The only|There are .*) obvious exit(s:| is)"
Mapper_Triggers disabled
TRACE: Executing trigger script "process_room_description"
Mapper adding room 9DDEE217, name: Jennette

587/587 3 822392 3725 off undrugged > 
TRACE: Matched alias "^s$"
Mapper_Triggers enabled
TRACE: Executing Plugin Two_Towers_Mapper_modified script "OnPluginSent"
s
This is the lush lobby of the Imperial Complex.  There are potted plants that line the walls, as well as at the base of the massive columns that
are also here.  There is a stairwell that leads down to a conference room for loyal citizens of the Empire.  There are some stormtroopers posted
near the stairwell, and they look like they mean to keep out anyone who isn't a loyal citizen of the Empire.
 
There are two obvious exits: north and down.
TRACE: Matched trigger "^(?P<roomdesc>\S.*\n(.*\n)*)(The only|There are .*) obvious exit(s:| is) (?P<exits>.*)\.\Z"
TRACE: Matched trigger "(The only|There are .*) obvious exit(s:| is)"
Mapper_Triggers disabled
TRACE: Executing trigger script "process_room_description"
Mapper adding room 8FA83799, name: from this area, is a Coffee House to the north, and the I...


So, it looks like somehow it grabbed the name of a mob, 'Jennette' between rooms 1 and 2, despite her name seeming to appear at a moment when
the triggers were disabled.

When I walked into room 3, it used a bit of room 2's description for the name, even tho I would have thought that would have been data from the prior
iteration overwritten by the current iteration when I walked into 3.

Hmm.

added the following code just before 'end' to the function 'process_room_description'


  name = nil
   
  roomdesc = nil

  collectgarbage()

  print ("name: ", name)


I had meant to add a print line for roomdesc but was adding and testing one line at a time and by happenstance captured a bizarre result where a player happened to walk through in the middle of testing.

While the triggers were seemingly disabled, it somehow grabbed 'Cherry enters.' and used it to name the next room I walked into 'Cherry enters'

Somehow, my attempts to disable the triggers and reset the variables are not accomplishing my intents:

1. to not collect data while the triggers are disabled
2. to not use old data from prior rooms
Top

Posted by Clafoutis   (29 posts)  Bio
Date Reply #5 on Fri 08 Nov 2019 03:42 PM (UTC)

Amended on Fri 08 Nov 2019 04:12 PM (UTC) by Clafoutis

Message

n
Welcome to the new Down on the Upside Cafe. Looking around in the dim room you find comfy couches together in pairs to promote discussion and
togetherness.  Small glass tables rest nearby for those hot drinks you can order from the waitress who undoubtedly must also be a struggling
artist. A rolling fire near the south end is surrounded by a few large pillows and a few good books on the mantle. The western wall has a small
stage with a microphone and chair for poets, musicians and storytellers to entertain and enlighten the crowd. A large board has a 'list' of
items on it for you to order. There is a door to the south, which seems to lead back to the street. There is also a stairwell going down, which
Jennette only allows certain people access to.
 You may also use the bulletin board here to post stories, jokes, and anything of artistic value for others to read.
 
Soft music of some foreign origin plays over the speakers.

There are two obvious exits: south and down.

Jennette

* Expression Board * is here.

587/587 3 822392 3725 off undrugged > Autosaving.
Cherry enters.
Cherry leaves down.
Cherry enters.
Cherry's Bodyguard enters.
Cherry leaves south.
Cherry's Bodyguard leaves south.
TRACE: Executing Plugin Two_Towers_Mapper_modified script "OnPluginInstall"
MUSHclient mapper installed, version 2.5
Added plugin
TRACE: Fired unlabelled timer 
TRACE: Matched alias "^s$"
Mapper_Triggers enabled
TRACE: Executing Plugin Two_Towers_Mapper_modified script "OnPluginSent"
s
You are standing on the eastern side of Senate Blvd.  To the east, you can catch a better glimpse of the Medical Facilities of Imperial City.
Also, from this area, is a Coffee House to the north, and the Imperial Complex to the south.
 
There are four obvious exits: south, north, east, and west.
TRACE: Matched trigger "^(?P<roomdesc>\S.*\n(.*\n)*)(The only|There are .*) obvious exit(s:| is) (?P<exits>.*)\.\Z"
TRACE: Matched trigger "(The only|There are .*) obvious exit(s:| is)"
Mapper_Triggers disabled
TRACE: Executing trigger script "process_room_description"
Mapper adding room C408F5CB, name: Cherry enters
name:  nil
Top

Posted by Clafoutis   (29 posts)  Bio
Date Reply #6 on Fri 08 Nov 2019 04:02 PM (UTC)

Amended on Fri 08 Nov 2019 04:28 PM (UTC) by Clafoutis

Message
It seems like I'm expecting it to evaluate the output starting from the next line to appear after the triggers are enabled.

Instead, it seems like there's some buffer it's reading from. All turning the triggers on does is tell it to begin evaluating from wherever it happens to be in the buffer.

Commented out the '<variable> = nil' lines and added a couple of lines to print asterisks to break up the text


TRACE: Executing Plugin Two_Towers_Mapper_modified script "OnPluginInstall"
MUSHclient mapper installed, version 2.5
TRACE: Matched alias "^n$"
Mapper_Triggers enabled
TRACE: Executing Plugin Two_Towers_Mapper_modified script "OnPluginSent"
n
Welcome to the new Down on the Upside Cafe. Looking around in the dim room you find comfy couches together in 
pairs to promote discussion and togetherness.  Small glass tables rest nearby for those hot drinks you can 
order from the waitress who undoubtedly must also be a struggling artist. A rolling fire near the south end 
is surrounded by a few large pillows and a few good books on the mantle. The western wall has a small stage 
with a microphone and chair for poets, musicians and storytellers to entertain and enlighten the crowd. A 
large board has a 'list' of items on it for you to order. There is a door to the south, which seems to lead 
back to the street. There is also a stairwell going down, which Jennette only allows certain people access to.
 You may also use the bulletin board here to post stories, jokes, and anything of artistic value for others 
to read.
 
Soft music of some foreign origin plays over the speakers.

There are two obvious exits: south and down.
TRACE: Matched trigger "^(?P<roomdesc>\S.*\n(.*\n)*)(The only|There are .*) obvious exit(s:| is) 
(?P<exits>.*)\.\Z"
TRACE: Matched trigger "(The only|There are .*) obvious exit(s:| is)"
Mapper_Triggers disabled
TRACE: Executing trigger script "process_room_description"
Mapper adding room 402F7BAE, name: togetherness
name:  togetherness
***********
roomdesc:  togetherness.  Small glass tables rest nearby for those hot drinks you can order from the waitress 
who undoubtedly must also be a struggling artist. A rolling fire near the south end is surrounded by a few 
large pillows and a few good books on the mantle. The western wall has a small stage with a microphone and 
chair for poets, musicians and storytellers to entertain and enlighten the crowd. A large board has a 'list' 
of items on it for you to order. There is a door to the south, which seems to lead back to the street. There 
is also a stairwell going down, which Jennette only allows certain people access to.
 You may also use the bulletin board here to post stories, jokes, and anything of artistic value for others 
to read.
 
Soft music of some foreign origin plays over the speakers.
***********

Jennette

* Expression Board * is here.

587/587 3 822392 3725 off undrugged > 
TRACE: Fired unlabelled timer 
TRACE: Matched alias "^s$"
Mapper_Triggers enabled
TRACE: Executing Plugin Two_Towers_Mapper_modified script "OnPluginSent"
s
You are standing on the eastern side of Senate Blvd.  To the east, you can catch a better glimpse of the 
Medical Facilities of Imperial City.  Also, from this area, is a Coffee House to the north, and the Imperial 
Complex to the south.
 
There are four obvious exits: south, north, east, and west.
TRACE: Matched trigger "^(?P<roomdesc>\S.*\n(.*\n)*)(The only|There are .*) obvious exit(s:| is) 
(?P<exits>.*)\.\Z"
TRACE: Matched trigger "(The only|There are .*) obvious exit(s:| is)"
Mapper_Triggers disabled
TRACE: Executing trigger script "process_room_description"
Mapper adding room 9DDEE217, name: Jennette
name:  Jennette
***********
roomdesc:  Jennette

* Expression Board * is here.

587/587 3 822392 3725 off undrugged > 
You are standing on the eastern side of Senate Blvd.  To the east, you can catch a better glimpse of the 
Medical Facilities of Imperial City.  Also, from this area, is a Coffee House to the north, and the Imperial 
Complex to the south.
***********
Top

Posted by Clafoutis   (29 posts)  Bio
Date Reply #7 on Fri 08 Nov 2019 04:57 PM (UTC)

Amended on Fri 08 Nov 2019 11:19 PM (UTC) by Clafoutis

Message
Looking into using to add a 'simulate' to my movement alias in order to push unique identifiers onto the room descriptions.

In theory, I can trigger off of this unique signifier instead of trying to get the trigger to guess what is and what isn't a room description.

Will take some work; will edit results into post if results are promising.

EDIT:

can simulate a 'testphrase' and trigger off of that but struggling to integrate 'testphrase' into


match="^(?P&lt;roomdesc&gt;\S.*\n(.*\n)*)(The only|There are .*) obvious exit(s:| is) (?P&lt;exits&gt;.*)\.\Z"


^testphrase(?...
testphrase(?...
^(?P&lt;roomdesc&gt;testphrase\S.*n...
^(?P&lt;roomdesc&gt;testphrase.*n...

doesn't seem to trigger. Probably need to take a break and come back with fresh eyes.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #8 on Fri 08 Nov 2019 09:57 PM (UTC)
Message

It seems like I’m expecting it to evaluate the output starting from the next line to appear after the triggers are enabled.

Instead, it seems like there’s some buffer it’s reading from. All turning the triggers on does is tell it to begin evaluating from wherever it happens to be in the buffer.

See How MUSHclient processes text arriving from the MUD

A line of input is collected and then trigger evaluation begins. If a low sequence (early) trigger enables a trigger that was previously off, and yet to be processed (in the evaluation sequence) then that same line will be sent to that trigger.

Also, script processing (in the script file, not send-to-script) is deferred until all triggers are processed. So you can disable triggers and then see that (previously handled) script functions are called.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Clafoutis   (29 posts)  Bio
Date Reply #9 on Sat 09 Nov 2019 12:54 AM (UTC)

Amended on Sat 09 Nov 2019 01:39 AM (UTC) by Clafoutis

Message
Thanks for the link; I'm digesting the implications and have bookmarked it for reference.

So, I've decided to back up and simply for it bit. I've adjusted the north moving alias to:


  <alias
   match="^n$"
   enabled="y"
   send_to="12"
   sequence="100"
   regexp="y"
  >
  <send>
   EnableTriggerGroup ("Mapper_Triggers", true)
   Note ("Mapper_Triggers enabled")
   Send("n")
   Simulate ("(*)")
    </send>
    </alias>	


Effectively, when I move north, I expect the vary next thing to be the next room's description. Here, I "mark" it with a unique notation. The hope is that eventually I can get a trigger to be able to differentiate between:

(*)some_text (this is a room description)

and

some_text (this is not a room description)

I have these triggers set up:


  <trigger
   enabled="n"
   lines_to_match="10"
   group="Mapper_Triggers"
   keep_evaluating="y"
   match="\(\*\)"
   multi_line="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
   Note ("match found")
  </send>
    </trigger>	
  <trigger
   enabled="n"
   group="Mapper_Triggers"
   keep_evaluating="y"
   match="(The only|There are .*) obvious exit(s:| is)"
   regexp="y"
   send_to="12"
   sequence="200"
  >
  <send>
  EnableTriggerGroup ("Mapper_Triggers", false)
  Note ("Mapper_Triggers disabled")
    </send>
    </trigger>


I expected to get:


Mapper_Triggers enabled
n
(*)Welcome to the new Down on the Upside Cafe. Looking around in the dim room you find comfy couches together in pairs to promote discussion and
match found
togetherness.  Small glass tables rest nearby for those hot drinks you can order from the waitress who undoubtedly must also be a struggling artist. A
rolling fire near the south end is surrounded by a few large pillows and a few good books on the mantle. The western wall has a small stage with a
microphone and chair for poets, musicians and storytellers to entertain and enlighten the crowd. A large board has a 'list' of items on it for you to
order. There is a door to the south, which seems to lead back to the street. There is also a stairwell going down, which Jennette only allows certain
people access to.
 You may also use the bulletin board here to post stories, jokes, and anything of artistic value for others to read.


Soft music of some foreign origin plays over the speakers.

There are two obvious exits: south and down.
Mapper_Triggers disabled

Jennette

* Expression Board * is here.

587/587 3 822392 3725 off undrugged >


I instead got:


Mapper_Triggers enabled
n
(*)Welcome to the new Down on the Upside Cafe. Looking around in the dim room you find comfy couches together in pairs to promote discussion and
match found
togetherness.  Small glass tables rest nearby for those hot drinks you can order from the waitress who undoubtedly must also be a struggling artist. A
match found
rolling fire near the south end is surrounded by a few large pillows and a few good books on the mantle. The western wall has a small stage with a
match found
microphone and chair for poets, musicians and storytellers to entertain and enlighten the crowd. A large board has a 'list' of items on it for you to
match found
order. There is a door to the south, which seems to lead back to the street. There is also a stairwell going down, which Jennette only allows certain
match found
people access to.
match found
 You may also use the bulletin board here to post stories, jokes, and anything of artistic value for others to read.
match found
 
match found
Soft music of some foreign origin plays over the speakers.
match found
match found
There are two obvious exits: south and down.
Mapper_Triggers disabled

Jennette

* Expression Board * is here.

587/587 3 822392 3725 off undrugged >


I experimented with turning 'keep_evaluating' off, but got the same result. I feel like I've done something horrifically wrong.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #10 on Sat 09 Nov 2019 06:25 AM (UTC)
Message
The multi-line thing is screwing you up. You are matching on "(*)" found anywhere over the last 10 lines. Which it was.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #11 on Sat 09 Nov 2019 06:27 AM (UTC)
Message
Personally I wouldn't be injecting packets like you are. Why not just set a global flag, which you can test in other triggers? Much simpler.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Clafoutis   (29 posts)  Bio
Date Reply #12 on Sat 09 Nov 2019 02:39 PM (UTC)

Amended on Sat 09 Nov 2019 05:55 PM (UTC) by Clafoutis

Message
Nick Gammon said:

The multi-line thing is screwing you up. You are matching on "(*)" found anywhere over the last 10 lines. Which it was.


Yea. It was instructive to see my assumptions shattered and examine why and how I was wrong.

Nick Gammon said:

Personally I wouldn't be injecting packets like you are. Why not just set a global flag, which you can test in other triggers? Much simpler.


So, I can flag a trigger for things like 'keep_evaluating' y or n, enable or disable a timer, etc.
I could set a variable and test it; if variable = true do x, else y. Right?

Isn't my problem that I can ask MUSHclient to grab a chunk of text, but I'm failing to express to MUSHclient what kinds of text to keep and
what to ignore?

Edit said:

There are examples elsewhere in the forum I need to review; I should set aside the rest of this post and the subsequent post until I have worked over them; sorry.


Two Towers seems to have a format where they begin room descriptions with 4 spaces, so that's easy to key off of. SWmud doesn't seem to
have a unique quirk of room descriptions to use.

One quirk of SWmud is that it does have what I think most mudders would think of as a room name. It treats it as a "short decription". If
brief mode is on, I'll get this short description instead of the regular description


Down on the Upside Cafe
[2: s, down]
Jennette

* Expression Board * is here.


As a side effect, it also formats the exits differently but that's fine.

Alternatively, regardless of brief mode, I can stand outside the room and 'lpeer [direction] [optional distance]' into the room and get
something similar


lpeer n 1
Down on the Upside Cafe
[2: s, down]
Jennette
* Expression Board * is here.


If the mud didn't frown on sending/triggering multiple commands to the mud all at once, I would have been tempted to write a script to maybe

move into a room (while brief mode was on)
omit everything but the roomname
look at the room while omitting the command sent from the output window

and get something like:


Down on the Upside Cafe
Welcome to the new Down on the Upside Cafe. Looking around in the dim room you find comfy couches together in pairs to promote discussion and
togetherness.  Small glass tables rest nearby for those hot drinks you can order from the waitress who undoubtedly must also be a 
struggling artist. A rolling fire near the south end is surrounded by a few large pillows and a few good books on the mantle. The western 
wall has a small stage with a microphone and chair for poets, musicians and storytellers to entertain and enlighten the crowd. A large 
board has a 'list' of items on it for you to order. There is a door to the south, which seems to lead back to the street. There is also a  
stairwell going down, which Jennette only allows certain people access to.
 You may also use the bulletin board here to post stories, jokes, and anything of artistic value for others to read.
 
Soft music of some foreign origin plays over the speakers.

There are two obvious exits: south and down.

Jennette

* Expression Board * is here.

587/587 3 843640 9475 off undrugged > 


maybe indent the 'room name' a little to help it stand out.
Top

Posted by Clafoutis   (29 posts)  Bio
Date Reply #13 on Sat 09 Nov 2019 02:54 PM (UTC)
Message
So, the 'exit' line is unique and reliably consistent. Looking at:

https://www.gammon.com.au/scripts/doc.php?function=GetLineInfo

I thinking about trying to write a function to grab the last 10ish lines from the buffer at the moment a trigger matches the exit line.

If I could consistently get the function to return line 10 as the exit line, I might be able to work backwards to get the room description. Something informally like


SetVariable ("roomdesc", "")

for line 9 to 1
   if line = [n,s,e,w, etc]
      then lineheader = line - 1
      end
   else lineheader = 1

for line lineheader to 9
   roomdesc = roomdesc + line


and then proceed to feed the roomdesc into the code the mapper already has to hash out a unique room number, etc.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #14 on Sat 09 Nov 2019 11:32 PM (UTC)
Message
Yes, what I try to do in situations like that is consider how I, as a human, recognise that I am looking at a room name, description, exits, contents, prompt, and other stuff. Then try to codify my thought processes into Lua code.

Your idea of working backwards from the next prompt may well be useful. Get a batch of rooms and see what there is consistent about them (eg. a leading space, length of line, colour of line, text in the line and so on). You may have to do something like "there is nothing special about the exits line, but it is always just before a prompt line".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


156,398 views.

This is page 1, subject is 4 pages long: 1 2  3  4  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.