Combining worm sources and mapping script

All and any discussion and development of the Mudlet Mapper.
Post Reply
Tobel
Posts: 12
Joined: Fri May 20, 2011 3:13 am

Combining worm sources and mapping script

Post by Tobel »

Hi there!

I was wondering if there would be a way to make a script to take the information gathered from doing worm source (lets you see all of the wormholes in your area) and utilize the mapper rf function (or perhaps another function I'm not aware of) to help me find out where they lead.

I'm still learning the warps, so it would be helpful to have an area along with the room name. For example, worm source gives the following format:

You sense a connection between In a tunnel of loose soil and Southern grasslands.

I know I could grab the first room and start the second room and save those as variables and use in conjunction with "rf room", but I'm unsure how do redisplay that information effectively, and also to capture a line that is on another line.

For example:
You sense a connection between Before the forge in the Gnoll fortress and Climbing through the
foothills.

Foothills wraps around to the next line, and I'm not familiar enough with mudlet yet to quite know how to grab a second line. Any assistance would be appreciated, thank you!

User avatar
demonnic
Posts: 717
Joined: Sat Dec 05, 2009 3:19 pm

Re: Combining worm sources and mapping script

Post by demonnic »

I'm not as familiar with the mapper functions as others, so I'll let them chime in on that part... but it sounds like you're playing one of the IRE muds... the best way to handle stuff that wraps is to let mudlet handle the wrapping. Something like CONFIG WRAPWIDTH 0 should do it for you. Then each line, no matter how many chars, is treated as one line by the trigger engine.

Tobel
Posts: 12
Joined: Fri May 20, 2011 3:13 am

Re: Combining worm sources and mapping script

Post by Tobel »

Threw something together and it seems to work well enough...
I trigger "You sense a connection between" to call mmp.roomFindT:

Code: [show] | [select all] lua
function mmp.roomFindT(query)
  if query:ends('.') then query = query:sub(1,-2) end
  local result = mmp.searchRoom(query)

  if type(result) == "string" or not next(result) then
    cecho("<grey> UNKNOWN.") return end

  cecho("<DarkSlateGrey>")


  if not tonumber(select(2, next(result))) then -- old style
    for roomid, roomname in pairs(result) do roomid = tonumber(roomid)
      cecho(string.format("  <LightSlateGray>%s<DarkSlateGrey> (<blue>",
        tostring(roomname)))
      echoLink(roomid, 'mmp.gotoRoom('..roomid..')', string.format("Go to %s (%s)", roomid, tostring(roomname)))
      cecho(string.format("<DarkSlateGrey>) in the <LightSlateGray>%s<DarkSlateGrey>.\n", tostring(mmp.areatabler[getRoomArea(roomid)])))
    end

  else -- new style
    for roomname, roomid in pairs(result) do roomid = tonumber(roomid)
      cecho(string.format("  <LightSlateGray><DarkSlateGrey> (<blue>",
        tostring(roomname)))
      echoLink(roomid, 'mmp.gotoRoom('..roomid..')', string.format("Go to %s (%s)", roomid, tostring(roomname)))
      cecho(string.format("<DarkSlateGrey>) in <yellow>%s<DarkSlateGrey>.\n", tostring(mmp.areatabler[getRoomArea(roomid)])))
    end
  end
end

Tobel
Posts: 12
Joined: Fri May 20, 2011 3:13 am

Re: Combining worm sources and mapping script

Post by Tobel »

My screenwidth is set to 0 but it still seems to not know how to handle the second line. Something I'll work on.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Combining worm sources and mapping script

Post by Heiko »

It's unlikely that the server breaks the line into 2 if you have wrapwidth=0. Increase the line wrap in Mudlet to 200 to find out. If it really is a server bug then you can use the multi conditon trigger engine features to get what you want. Otherwise, I'd go for a simple regex pattern and grab both room titles right away and then look up the room ids and set the warp links as special exits in the mapper - and add them to a persistent table or a db in case the warp gates need to be removed from special exits at some point (I don't know anything about your game, just guessing).

Post Reply