[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Mapper plugin for Two Towers
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Mapper plugin for Two Towers

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


Pages: 1 2  3  4  5  6  

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Sun 29 Aug 2010 11:33 PM (UTC)

Amended on Thu 02 Sep 2010 10:04 AM (UTC) by Nick Gammon

Message
Below is my first attempt at a mapper for the Twin Two Towers MUD.

It certainly isn't perfect, but it might help others get further.

Basically the problem with a mapper is to detect unique rooms, and in the case of this MUD I fairly quickly stumbled into a place where each room had the same description, namely:


    You stand in a very dark tunnel. All around you shadows hide 
the sides of the walls. Every once in a while you pass a torch
which gives off a small amount of light that is consumed by the
darkness. In the distance you hear the dripping of water and an 
occasional hammering of stone.


Also rooms don't seem to have names per se, so in the absence of a better idea I have put in the partial room hash (better than nothing, maybe).

To use, install as per the instructions below. Then you have to "teach" it by walking around. You should start to see squares appearing with you in the middle. You are best off backtracking as you enter each room. (So if you go west from A to B, it knows A leads to B. Then go back east again, so it knows B leads back to A).

This version just stores the map in the plugin state file. It could be modified to use a SQLite3 database, which would then let you share the map between different characters.

It is based on Simple_Mapper.xml from this page:

http://www.gammon.com.au/forum/bbshowpost.php?id=10138&page=7

The only real change was to make a multi-line trigger that tries to detect room descriptions, namely starting with 4 spaces, then multiple lines, followed by "The only obvious exits are xxx" or "The only obvious exit is xxx".

Template:saveplugin=Two_Towers_Mapper To save and install the Two_Towers_Mapper plugin do this:
  1. Copy between the lines below (to the Clipboard)
  2. Open a text editor (such as Notepad) and paste the plugin into it
  3. Save to disk on your PC, preferably in your plugins directory, as Two_Towers_Mapper.xml
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file Two_Towers_Mapper.xml (which you just saved in step 3) as a plugin
  7. Click "Close"



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

<muclient>
<plugin
   name="Two_Towers_Mapper"
   author="Nick Gammon"
   id="565a2ddd934aca9913894ad4"
   language="Lua"
   purpose="Mapper for LOTR Two Towers"
   save_state="y"
   date_written="2010-08-30"
   requires="4.51"
   version="1.1"
   >

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   lines_to_match="10"
   match="^\s{4}(?P&lt;roomdesc&gt;.*\n(\S.*\n)*)\s{4}The only obvious exit(s are| is) (?P&lt;exits&gt;.*)\.\Z"
   multi_line="y"
   regexp="y"
   script="process_room_description"
   sequence="100"
  >
    </trigger>
</triggers>

<aliases>
<alias
   match="^mapper find ([\w* %d/&quot;]+)$"
   enabled="y"
   sequence="100"
   script="map_find"
   regexp="y"
  >
  
  </alias>  
  </aliases>
  

<!--  Script  -->


<script>
<![CDATA[

local MAX_NAME_LENGTH = 60
local MUD_NAME = "Two Towers"

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


[EDIT] Amended to fix up problems with room detection. Also put room name on top of map.


Example screenshot:



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 30 Aug 2010 12:51 AM (UTC)
Message
Amended plugin above slightly.

It was sometimes getting extra spaces in room descriptions and thus treating the same room as two different ones.

Also now put the first 60 characters of the description, up to the first period, as the room name:



Also added an alias "mapper find x" where "x" is something you are looking for (eg. "mapper find inn").

Example output:


mapper find sign

This is the bank of Belegost is the room you are in
This is a cozy pipe shop, situated in a nook off the tunn... - 3 rooms away
This is the first sign of civilization that you have sigh... - 4 rooms away
There was 1 match which I could not find a path to within 30 rooms.


That should make it easier to find stuff.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Mon 30 Aug 2010 12:58 AM (UTC)
Message
I also find that in places the mapper doesn't show the real situation because you are "lost" in tunnels. This particularly happens if multiple rooms have identical descriptions and exits.

For example:


    You stand in a very dark tunnel. All around you shadows hide 
the sides of the walls. Every once in a while you pass a torch
which gives off a small amount of light that is consumed by the
darkness. In the distance you hear the dripping of water and an 
occasional hammering of stone.
    The only obvious exits are west and east.


Now if you go west and get the same description it thinks you haven't moved. I suppose you expect this, because the MUD is trying to confuse you, and it succeeds. :)

But if you keep walking and escape from the maze it should re-synchronize OK.

Also added debugging message like this:


Mapper adding room 7C01B73F, name: You stand in a very dark tunnel


So if you see that, the mapper has added to its knowledge of the MUD layout.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 30 Aug 2010 01:11 AM (UTC)
Message
I should point out that there is nothing in this plugin that is really specific to this MUD (apart from the layout of a room description). It doesn't use MXP, it doesn't use telnet negotiation. There is only a single multi-line trigger that tries to match a room description/exits line.

If you can adapt that trigger to suit your MUD you should be able to use it practically anywhere.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Jerrid   (20 posts)  [Biography] bio
Date Reply #4 on Mon 30 Aug 2010 02:06 AM (UTC)
Message
First off, let me give a very big thanks to every one helping me, especially those that actually took the time to go into the game...

Now, I did all this plus extra stuff that was directed to me to do. But when I go to File, Plugins... and then add the twin_towers_mapper, it says "unable to create the plugin save state file:"

Then "There was a problem loading the plugin"

There are two pages that pull up that covers the entire MUSHclient screen. One is white that I am assuming is what was copied from the notepad and then when I close that one there is an orange looking screen that says "Line 14: Plugin requires MUSHclient version 4.51 or above (problem in this file)" But as far as I know, the latest MUSHclient is 4.43...

So I updated the MUSHclient. Problem now though is that when I try to save it is fine, but when I try to add the plug in from the game file, it does not show at all. I double checked and at first could not find it in the game folder from desk top, but then looking under all files it shows it is already saved. I even resaved it and over write it. But in the game it does not show, even if I search under all instead of just XML. I even shut down and restarted MUSHclient more than once.

Any suggestions?
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #5 on Mon 30 Aug 2010 02:11 AM (UTC)
Message
Jerrid said:
Now, I did all this plus extra stuff that was directed to me to do. But when I go to File, Plugins... and then add the twin_towers_mapper, it says "unable to create the plugin save state file:"

Go into the plugins directory (<mushclient directory>/worlds/plugins) and create a new folder "state". Sometimes you have to do that manually, but it's a one-ime thing.

Jerrid said:
Then "There was a problem loading the plugin"

There are two pages that pull up that covers the entire MUSHclient screen. One is white that I am assuming is what was copied from the notepad and then when I close that one there is an orange looking screen that says "Line 14: Plugin requires MUSHclient version 4.51 or above (problem in this file)" But as far as I know, the latest MUSHclient is 4.43...

That's a big pet peeve of mine. The version you first see on the download page is the so-called "stable" version. If you look really hard, there's a section that says "Want the very latest version?" that links you to the Announcements forum here.

The latest version, 4.58, was released in this forum post:
http://www.gammon.com.au/forum/?id=10512

Jerrid said:
So I updated the MUSHclient. Problem now though is that when I try to save it is fine, but when I try to add the plug in from the game file, it does not show at all. I double checked and at first could not find it in the game folder from desk top, but then looking under all files it shows it is already saved. I even resaved it and over write it. But in the game it does not show, even if I search under all instead of just XML. I even shut down and restarted MUSHclient more than once.

I assume you're talking about the Open Plugin dialog. Plugins usually live in <mushclient directory>/worlds/plugins, so you'll want to put it there unless you have a good reason not to. That's usually whree the Open Plugin dialog goes first.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Mon 30 Aug 2010 02:14 AM (UTC)
Message
Jerrid said:


So I updated the MUSHclient. Problem now though is that when I try to save it is fine, but when I try to add the plug in from the game file, it does not show at all. I double checked and at first could not find it in the game folder from desk top, but then looking under all files it shows it is already saved. I even resaved it and over write it. But in the game it does not show, even if I search under all instead of just XML. I even shut down and restarted MUSHclient more than once.

Any suggestions?


You've lost me a bit with that. In the Plugins dialog (File menu -> Plugins) you just browse for where you saved the plugin file. Desktop, My Documents, whatever.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #7 on Mon 30 Aug 2010 02:59 AM (UTC)
Message
Jerrid said:
So I updated the MUSHclient. Problem now though is that when I try to save it is fine, but when I try to add the plug in from the game file, it does not show at all. I double checked and at first could not find it in the game folder from desk top, but then looking under all files it shows it is already saved. I even resaved it and over write it. But in the game it does not show, even if I search under all instead of just XML. I even shut down and restarted MUSHclient more than once.

Attempted translation:

Jerrid said:
So I updated MUSHclient. Problem now though is that when I try to save it is fine, but when I try to add the plugin from MUSHclient, it does not show up in the file browser at all. I double checked and at first could not find it in the MUSHclient folder from the Desktop, but then changing the file filter to "All files" it shows it is already saved. I even tried re-saving it again. But in MUSHclient it does not show up, even if I use "All files" instead of just XML. I even shut down and restarted MUSHclient more than once.



This brings up another point: Save it with a .xml extension. Make sure it doesn't have any hidden .txt extension, because Windows sometimes does that. Copy it into Wordpad and save it as .xml from there, I don't think it's as annoying.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Jerrid   (20 posts)  [Biography] bio
Date Reply #8 on Mon 30 Aug 2010 04:15 AM (UTC)
Message
I see... I thought I was suppose to save it under the games file plugin folder. But now I just saved it under desktop and loaded it from there and it works!!! Has a nice green glow to it. However, (And I think I read some where about this.) the map doesn't show previous rooms you were in unless you back out on purpose? Like if I go n, n, n, n, all I see is me not moving on the map screen. But if I were to now go s, s, s, s, I would see all four rooms... But if I were to now go e, I am on a screen with a single box, but I go back out where I came from, w, the entire map now shows up.

It even shows descriptions for the rooms which is nice! Is there a work around for the rooms not showing until I go back out where I came from though? Even if not, I do appreciate all that you have done. Should I or some one from here tell The Two Towers game that a map feature is now implemented for MUSHclient? Or does more work need to be done if such an announcement will be made?

PS. Does the map save it self or would I have to go through rooms again to redo it all? And I have also seen a "fat" arrow pointing up... what does that mean? After trying to go north an then back down it looks like a thicker line than the regular connecting lines for rooms... I have to go s, s, or n, n to get to the other room on the map screen. Perhaps because there is not much going on as in big descriptions like there would be normally? Also when I do go south the rest of the map besides the four adjoining rooms disappear until I go north and then all the map so far appears again. I go back south and again only the four adjoining rooms show.

Thank you again so much. I wish I could donate money for your hard work. I was not expecting people to actually go in game and so quickly! You deserve donations even before that for all the free stuff you have done, but I have no money... literally. But I can spread the word of MUSHclient and if you have a Facebook page I could link it etc.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Mon 30 Aug 2010 04:33 AM (UTC)
Message
Jerrid said:

I see... I thought I was suppose to save it under the games file plugin folder. But now I just saved it under desktop and loaded it from there and it works!!! Has a nice green glow to it. However, (And I think I read some where about this.) the map doesn't show previous rooms you were in unless you back out on purpose? Like if I go n, n, n, n, all I see is me not moving on the map screen. But if I were to now go s, s, s, s, I would see all four rooms... But if I were to now go e, I am on a screen with a single box, but I go back out where I came from, w, the entire map now shows up.



Yes that is expected behaviour, and I was trying to describe it, although it isn't easy until you see it.

Basically it doesn't assume that two rooms connect until you have gone back and forwards. eg.



Inn --> Courtyard


Now if you go from the Inn to the Courtyard it knows (next time you are in the Inn) that it leads to the Courtyard.

BUT - until you go from the Courtyard back into the Inn, it doesn't know it leads back. It could guess, but there are such things as one-way exits.

So once you go back, it then looks like:


Inn <--> Courtyard


Until that time you get a little arrow on the line, to show it is a one-way exit.

Jerrid said:

Does the map save it self or would I have to go through rooms again to redo it all?


It should remember everything if you have the "state" saving working. Try pressing Ctrl+S, if there is no error message, then it saved. Also try closing down, and restarting. Once you type "look" (so it knows where you are) you should see the whole map as at what you had last time.

Jerrid said:

And I have also seen a "fat" arrow pointing up... what does that mean?


It draws where you have been recently with thicker lines. This is useful once you have quite a few rooms on the map, the fatter lines shows where you have been walking. It thins out after about 5 minutes. This is so you might look up and say "oh I want to go back to where I was a couple of minutes ago" - so you look at where the thick line went.

Jerrid said:

Thank you again so much.


You are welcome, I hope you enjoy it.

And hopefully the plugin shows how to adapt the mapper to other MUDs as well.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Mon 30 Aug 2010 04:42 AM (UTC)
Message
Make sure you grab the updated plugin - I improved it since the first posting.

It should have version 1.1 near the top of it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #11 on Mon 30 Aug 2010 04:48 AM (UTC)
Message
Below is an example of the thicker line:



The circled part is where I just walked.

Also in case you didn't notice you can click on the star at the bottom to open up a configuration window (eg. to change its size).

You can also drag it around by the room name.

Finally, you can left-click on any room to walk to it (this may fail if there are confusing room connections).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Jerrid   (20 posts)  [Biography] bio
Date Reply #12 on Mon 30 Aug 2010 05:12 AM (UTC)
Message
Nick Gammon said:

Make sure you grab the updated plugin - I improved it since the first posting.

It should have version 1.1 near the top of it.


I do not see an upated plug in... unless you are not talking about what I had to copy and past into wordpad and then save it? When I go to the top of this thread it says version 1.0... so I am not sure I am understanding you.

Nick Gammon said:
And hopefully the plugin shows how to adapt the mapper to other MUDs as well.


How would I do that? If I wanted to try another MUD how could I adapt it? Is it a simple process of changing one number to another or putting a / here or there or is there some serious coding and messing with a game to understand it? And even if it is simple... to me it would be hard. Hahahaha!

I can tell you one thing though... I am much more enjoying this game. Thank you!
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #13 on Mon 30 Aug 2010 05:22 AM (UTC)
Message

<plugin
   name="Twin_Towers_Mapper"
   author="Nick Gammon"
   id="565a2ddd934aca9913894ad4"
   language="Lua"
   purpose="Mapper for LOTR Twin Towers"
   save_state="y"
   date_written="2010-08-30"
   requires="4.51"
   version="1.1"
   >


Line in bold. Not the XML version which is still 1.0.

Jerrid said:

How would I do that?


That was really addressed at people who play other MUDs and have some experience doing regular expressions. Because each MUD is different it isn't usually just a "change one number" thing, unfortunately.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #14 on Mon 30 Aug 2010 05:30 AM (UTC)

Amended on Mon 30 Aug 2010 05:34 AM (UTC) by Nick Gammon

Message
To help anyone who wants to edit the trigger, this is how it breaks down.

First, an example room description:


    You stand in a very dark tunnel. All around you shadows hide 
the sides of the walls. Every once in a while you pass a torch
which gives off a small amount of light that is consumed by the
darkness. In the distance you hear the dripping of water and an 
occasional hammering of stone.
    The only obvious exits are west and east.


Now to match that, the regexp looks like this:


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


And each part means:


  • ^ --> start of a line
  • \s{4} --> 4 spaces
  • (?P<roomdesc>.*\n --> a tag named "roomdesc" consisting of anything followed by a newline; and then ...
  • (\S.*\n)*) --> NOT a space, followed by anything, followed by a newline, zero or more times
  • \s{4} --> 4 spaces
  • The only obvious exit(s are| is) --> Literally: The only obvious exits are (or: exit is)
  • (?P<exits>.*) --> a tag named "exits" consisting of anything
  • \. --> a period (at the end of the exits)
  • \Z --> end of "subject" (that is, end of the multiple-line trigger)


So as a guide, you could make a regular expression along those lines that matches how your MUD's room descriptions look.

For more details see: http://mushclient.com/regexp

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


78,946 views.

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

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]