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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Learning Mapper with MSDP

Learning Mapper with MSDP

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


Pages: 1 2  

Posted by Xinefus   (106 posts)  [Biography] bio
Date Fri 05 Jun 2020 04:44 PM (UTC)

Amended on Fri 05 Jun 2020 04:45 PM (UTC) by Xinefus

Message
Good afternoon folks,

I am currently trying to adapt the Learning Mapper (http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=14607) with some of the info that my MUD reports via MSDP. The following is what I can see when using msdpdebug 1 (simple):

msdp[ROOM_NAME]=Central City: Forester Road'
msdp[ROOM_EXITS]=east,south,west
msdp[ROOM_VNUM]=1406


I have added a OnPluginBroadcast to the learning_mapper.lua as seen: https://github.com/DBNU-Braska/DBNU/blob/master/Learning_Mapper.lua#L1248-L1279 .

I am having difficulty in understanding how to push the info from the handler to the mapper. Line 1273 was my attempt at ensuring I get all the right info..

The handler can be found in the same Git: https://github.com/DBNU-Braska/DBNU/blob/master/MSDPHandler.xml


Any nudges in the right direction would be appreciated.

Thank you.
[Go to top] top

Posted by Nick Gammon   Australia  (22,966 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sat 06 Jun 2020 06:21 AM (UTC)

Amended on Sat 06 Jun 2020 06:29 AM (UTC) by Nick Gammon

Message
Quote:


mapper.draw(current_room, room_exits, room_name)



You are just inventing the arguments to mapper.draw here.

If you look at http://www.gammon.com.au/forum/?id=12635 you will see that mapper.draw draw takes a single argument, the room number (or room ID) that you want to draw. You can't just pass down exits and the room name, in an undocumented way, and hope for the best.

The mapper needs to know about all rooms (that it finds are linked to this one) and their exits. So what it does is "call back" to find the details about your current room, and then the linked rooms, and the rooms that link to that, and so on.

So, you implement the function get_room along these lines:


-- -----------------------------------------------------------------
-- mapper 'get_room' callback - it wants to know about room uid
-- -----------------------------------------------------------------
function get_room (uid)
 
  local room = { }  -- a table of stuff about this room

  -- fill out information about room "uid" here

  return room
end -- get_room

- Nick Gammon

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

Posted by Nick Gammon   Australia  (22,966 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sat 06 Jun 2020 06:28 AM (UTC)
Message
Quote:

I have added a OnPluginBroadcast to the learning_mapper.lua as seen: https://github.com/DBNU-Braska/DBNU/blob/master/Learning_Mapper.lua#L1248-L1279 .


If you want to use the learning mapper then you shouldn't need to play with the Lua code there at all. It is designed to absorb information as you walk around and save it to its internal database.

However the learning mapper is probably not the most appropriate here. You don't need to learn line types, exits and so on if the MUD actually supplies them. So, adapting the mapper in my reply #1 is probably the way you want to go.

- Nick Gammon

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

Posted by Xinefus   (106 posts)  [Biography] bio
Date Reply #3 on Sat 06 Jun 2020 09:58 AM (UTC)
Message
Thanks for referencing the link to 'how to use on your own mud'


I will work through this part and it looks like it will help me to learn how all the parts of the mapper work.
[Go to top] top

Posted by Xinefus   (106 posts)  [Biography] bio
Date Reply #4 on Sun 07 Jun 2020 11:11 AM (UTC)

Amended on Sun 07 Jun 2020 07:09 PM (UTC) by Xinefus

Message
Ref: https://github.com/DBNU-Braska/DBNU/blob/master/Learning_Mapper.xml

So I have followed the mapper up to here. You can find the xml at ref.

I still have the print() on so I can see and this is a few examples of what I get.

>e
>>>msdp[ROOM_EXITS]=north,south,west<<<
Room name:  &WCentral City:&Y Gears and Things
the vnum is:  1372
the exits:  n,s,w
>>>msdp[ROOM_NAME]=Central City: Broadway<<<
Room name:  Central City: Broadway
the vnum is:  1372
the exits:  n,s,w
>>>msdp[ROOM_VNUM]=1301<<<
Room name:  Central City: Broadway
the vnum is:  1301
the exits:  n,s,w
>w
>>>msdp[ROOM_EXITS]=east<<<
Room name:  Central City: Broadway
the vnum is:  1301
the exits:  e
>>>msdp[ROOM_NAME]=&WCentral City:&Y Gears and Things<<<
Room name:  &WCentral City:&Y Gears and Things
the vnum is:  1301
the exits:  e
>>>msdp[ROOM_VNUM]=1372<<<
Room name:  &WCentral City:&Y Gears and Things
the vnum is:  1372
the exits:  e


The first thing that I find interesting is that I do not know how to get the first room name correct. It seems to name/leave it as the vnum.

Second, how do I remove the colour codes from the rooms? Right now, some of the rooms return the colour tags as you can see in the code above.

I was about to add in the area, but I do not want to introduce any more potential errors yet.

Thanks!
[Go to top] top

Posted by Fiendish   USA  (2,513 posts)  [Biography] bio   Global Moderator
Date Reply #5 on Mon 08 Jun 2020 01:06 AM (UTC)

Amended on Mon 08 Jun 2020 01:09 AM (UTC) by Fiendish

Message
Quote:
>>>msdp[ROOM_NAME]=Central City: Broadway<<<
Room name:  Central City: Broadway
The first thing that I find interesting is that I do not know how to get the first room name correct. It seems to name/leave it as the vnum.

Your shown output disagrees with you.

Quote:
how do I remove the colour codes from the rooms?

You look for them and strip them out. That can either be done by the server or by the client. Which are you asking for?

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Xinefus   (106 posts)  [Biography] bio
Date Reply #6 on Mon 08 Jun 2020 09:54 AM (UTC)

Amended on Mon 08 Jun 2020 09:55 AM (UTC) by Xinefus

Message
Fiendish said:

You look for them and strip them out. That can either be done by the server or by the client. Which are you asking for?

I would probably want to do it on the client side. I have yet to get access to the server side to do any changes. I believe there is probably an easier way to do it on the server through the Kavir snippet of MSDP.

Let me explain a little on that output paste as I would like to understand a little of it as well;
Quote:

>e -- I just moved east
>>>msdp[ROOM_EXITS]=north,south,west<<< -- Handler output of new room exits
Room name: &WCentral City:&Y Gears and Things -- mapper output of old room name
the vnum is: 1372 -- mapper output of old room vnum
the exits: n,s,w -- mapper output of new room exits

>>>msdp[ROOM_NAME]=Central City: Broadway<<< -- Handler output of new room name
Room name: Central City: Broadway -- mapper output of new room name
the vnum is: 1372 -- mapper output of old room vnum
the exits: n,s,w -- mapper output of new room exits

>>>msdp[ROOM_VNUM]=1301<<< -- Handler output of new room vnum
Room name: Central City: Broadway -- mapper output of new room name
the vnum is: 1301 -- mapper output of new room vnum
the exits: n,s,w -- mapper output of new room exits
[Go to top] top

Posted by Fiendish   USA  (2,513 posts)  [Biography] bio   Global Moderator
Date Reply #7 on Mon 08 Jun 2020 04:07 PM (UTC)

Amended on Mon 08 Jun 2020 04:09 PM (UTC) by Fiendish

Message
Quote:
I would probably want to do it on the client side.

Assuming that && is how you escape a literal &,
function strip_colors(s)
   s = s:gsub("&&", "\0")
   s = s:gsub("&.", "")
   s = s:gsub("%z", "&")
   return s
end



Quote:
Let me explain a little on that output paste

Yes. I don't see a problem.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Xinefus   (106 posts)  [Biography] bio
Date Reply #8 on Thu 11 Jun 2020 01:23 PM (UTC)
Message
Fiendish said:


Assuming that && is how you escape a literal &,
function strip_colors(s)
   s = s:gsub("&&", "\0")
   s = s:gsub("&.", "")
   s = s:gsub("%z", "&")
   return s
end



Thank you Fiendish, this is working almost flawlessly. The only issue I have is that room names (and probably descs, later problem) also are not consistent in how they apply colour coding. Many of them are using the method described in strip_colors() however, some are using xterm, or even a mix of both.
msdp[ROOM_NAME]=[38;5;093mMayor's Office[0;00m

That is an example.

Would I be able to add a couple more lines within strip_colors() to remove that as well? After reading https://www.gammon.com.au/forum/?id=7761&reply=6#reply6 I can see what that string is that I would want to remove.

So essentially, I will want to remove everything from [ to m at the start and end of the sequence. I'm having trouble understanding the different pattern matches to make this work correctly.

I'm also wondering about the %z line in your code. What does that do?
[Go to top] top

Posted by Xinefus   (106 posts)  [Biography] bio
Date Reply #9 on Thu 11 Jun 2020 02:41 PM (UTC)

Amended on Thu 11 Jun 2020 03:19 PM (UTC) by Xinefus

Message
Ok, to show that I'm not a complete incompetent; I have given a good shot at trying to figure this out.

I now have
function strip_colors(s)
  s = s:gsub("&&", "\0")
  s = s:gsub("%p[%d+;]+m", "")
  s = s:gsub("&.", "")
  s = s:gsub("%z", "&")
  return s
end

Now the room shows like this:
Quote:
>>>msdp[ROOM_NAME]=[38;5;093mMayor's Office[0;00m<<<
Room name: Mayor's Office

Yet on the mapper, it doesn't quite show up right. It has a white square symbol at the start and end.

I'm not sure how that is getting in there..
[Go to top] top

Posted by Fiendish   USA  (2,513 posts)  [Biography] bio   Global Moderator
Date Reply #10 on Thu 11 Jun 2020 03:13 PM (UTC)

Amended on Thu 11 Jun 2020 03:18 PM (UTC) by Fiendish

Message
Quote:
some are using xterm, or even a mix of both

Lol. Not to worry. We can compensate for that.

Quote:
I will want to remove everything from [ to m

It's slightly more complicated, because that [ isn't really where the sequence starts. The sequence actually starts with an invisible ESC (ASCII character 27) right before it. Luckily for you, though, MUSHclient has a built in StripANSI function that you should be able to use. https://www.mushclient.com/scripts/doc.php?function=StripANSI

Quote:
I'm also wondering about the %z line in your code. What does that do?

The two lines
s = s:gsub("&&", "\0")

and
s = s:gsub("%z", "&")

counterbalance each other. The first one says "If there are any escaped ampersands, meaning that we want a literal ampersand and not a color code, temporarily replace them with a zero byte (\0)." We do that so that removing all other instances of & is easy and safe. Then the latter one says "Now that we've removed all of the & codes, let's undo the temporary zero byte replacement and put the literal ampersands back in." I choose "\0" as the temporary replacement because I know that it won't organically appear anywhere else in the text. It just happens that if you want to match on \0 using gsub in Lua you have to use %z.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Xinefus   (106 posts)  [Biography] bio
Date Reply #11 on Thu 11 Jun 2020 03:25 PM (UTC)
Message
Thank you again!

I have been trying to figure that one out all morning. I kind of figured there must be some other sort of code in there that I wasn't taking into account..

Now onto bigger and better things! I'll be back when I hit another hiccup.
[Go to top] top

Posted by Xinefus   (106 posts)  [Biography] bio
Date Reply #12 on Tue 16 Jun 2020 05:00 PM (UTC)
Message
Good day folks,

I have been able to find a mapper that someone has already adapted for MSDP and using what my MUD outputs I have been able to make it work. Ref: https://github.com/DBNU-Braska/DBNU/blob/master/DBNU_Mapper.xml


        @                 #              
        |                 |              
        2                 #              
        |                 |              
        #-#-@-@-#-@-A-#-#-@              
                                                                                  

This room is filled with intricate tools,

In the above clip, it shows the automap (I am 'A'). Is there a way to implement some of these details into the mapper? The ones I am most interested in are "Sector Type" and (probably more difficult) entities in that room. In the above, the '@' and '2' denote there is a mob/pc in that room. I'm not exactly sure how this could be implemented as it also requires the pc to be wearing the proper glasses and they have a certain range on the automap.

However, is there a way that I could implement (I'm guessing through an addition to the msdp code) the sector type and be able to use this to influence the mapper (i.e. background colour, border colour, etc).

Also, I assume that the mapper cannot map more than 1 room at a time? Is it able to do connected rooms? What sort of information does it need to be able to do that? (room exit + exit vnum?) I'm just trying to replicate that automap as much as possible client-side because the server one can get a bit laggy at times. But client-side, once the player has mapped an area, it will be super fast.

Thanks!

Thanks.
[Go to top] top

Posted by Fiendish   USA  (2,513 posts)  [Biography] bio   Global Moderator
Date Reply #13 on Tue 16 Jun 2020 06:15 PM (UTC)
Message
Quote:
I have been able to find a mapper that someone has already adapted for MSDP
Yikes. Well, they ripped out the ability to set sector type colors, so...

Quote:
is there a way that I

Yes

Quote:
sector type and be able to use this to influence the mapper (i.e. background colour, border colour, etc).

Send it from the server and use it in the plugin in the right place, of course.

Search for the word "terrain" in Nick's original GMCP mapper. https://github.com/nickgammon/plugins/blob/master/GMCP_Mapper.xml

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Xinefus   (106 posts)  [Biography] bio
Date Reply #14 on Wed 17 Jun 2020 11:52 AM (UTC)

Amended on Wed 17 Jun 2020 12:29 PM (UTC) by Xinefus

Message
Ref: a. https://github.com/nickgammon/plugins/blob/master/GMCP_Mapper.xml - GMCP_Mapper
b. https://github.com/DBNU-Braska/DBNU/blob/master/DBNU_Mapper.xml - DBNU_Mapper (MSDP)

Aww, now look what you went and did! I was understanding things relatively well up to now...

And yes, I know can 'x' be done is always possible. Just not possible with my current skill level.

I envision the mapper being able to:

  • Automap an area either by walking through it, or maybe it doing some of it by itself dependent on what the pc is able to see (wrt the in-game automap - i.e. radius of 5 rooms).
  • Show/hide rooms that are in different areas (usually this is by .are). This will help with a bit of overlapping I currently am getting in some places.
  • Auto set the sector (as previously stated) so that a person will know what is coming up.
  • Show entities in surrounding rooms (this is enabled by a wearable item in-game).

I know that for a lot of this I am going to need to update some of the code so that I actually can get more info coming from the server. Right now it does not report sectortype or exit vnum. I believe I need this to enable more of what I am asking for here. Can I have a bit of guidance on what I should be doing first?
Right now the mapper works pretty well as per my git. But, because I'm not super great at this, I may have introduced errors without knowing it and am actively looking for someone to help check my progress.
I am up for going back to Nick's GMCP_Mapper and 'porting' it to use MSDP. I would think the most of the changes will need to be done within OnPluginBroadcast to ensure the mapper understands what it is receiving.

Your thoughts and encouragement are very welcomed. Thank you.
[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.


36,236 views.

This is page 1, subject is 2 pages long: 1 2  [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 HostDash]