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
➜ Mapper for DSL
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Ashass
(50 posts) Bio
|
Date
| Fri 17 Dec 2010 01:37 AM (UTC) Amended on Fri 17 Dec 2010 02:08 AM (UTC) by Ashass
|
Message
| So I'm trying to understand the mapper plugin you wrote, and I've been experimenting with some of the things you've done for the (magic materia?) mud, and have had limited success.
When I load the mapper, it shows teh cyan box that is much client mapper, v2.5, written by nick, dsl (which i assume is the world name)
When I try moving, no new rooms are written to the box itself, and as far as I can tell, nothing is happening.
Added some of the debug prints I saw floating around there...
-- -----------------------------------------------------------------
-- 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
print ("Fixing exit for", from_room, "to go to", 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 ("Moving", 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
And the OnPluginSent - Moving <direction> message prints fine, but there is no following prints based on where I'm moving, which makes me think that the mapping plugin is not recognizing when I changed rooms (Which... really isn't a surprise.)
What I'm trying to do, is figure out how to break down the following...
When you move, you will see something like this:
w
Within the Maze
Tall lusterous green hedges rise high above you, blocking your vision
from seeing over top of them. Hanging from metal posts, a lantern glows
brightly, lighting the crushed rocks beneath your feet. The hedges
themselves are well kept and neatly trimmed, but it matters not which way
you look for it all appears to be the same.
[Exits: east south ]
A Zandreyan follower wanders here.
<362/362hp, 141/141m, 172/172mv, (Within the Maze)[ES]> 1:30pm.
So from top to bottom, w is the direction (input, west)
Within the Maze is the room name
Then you have the description of the room
Then the exits
Then any mobs in the room
Terminated by your prompt
Any recommendations on how to actually catch the movement? | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Fri 17 Dec 2010 03:09 AM (UTC) Amended on Fri 17 Dec 2010 03:10 AM (UTC) by Nick Gammon
|
Message
| Well, detecting a room change, and getting the room description, no more and no less, is really the challenging part. :)
In the case of Materia Magica which I did here:
http://www.gammon.com.au/forum/?id=10667
I noticed that the room name was yellow, followed by a line of hyphens in blue, followed by some other stuff which was the ASCII map, and then a blank line (something like that).
So, the mapper has a sort of "state engine" where it starts off looking for a line in yellow, and then if that is followed by a line of hyphens, it assumes it probably has a room change.
Now for you, you have to try to extract out everything that seems to apply to room, but not other things (like chats).
So, in your example, assuming every room looks like this:
Within the Maze
Tall lusterous green hedges rise high above you, blocking your vision
from seeing over top of them. Hanging from metal posts, a lantern glows
brightly, lighting the crushed rocks beneath your feet. The hedges
themselves are well kept and neatly trimmed, but it matters not which way
you look for it all appears to be the same.
[Exits: east south ]
- You have a room name (hopefully in a different colour).
- Then you have a description that starts with two spaces (do they always?).
- Then you have a blank line.
- Then you have an Exits line.
So basically you provisionally think you have a room change when you see the room name, especially if it is coloured a distinct colour. So you save that somewhere, and save that as "state 1".
Then if the next line starts with two spaces (and therefore isn't a prompt line) then you say "well this is probably the description". So you switch to "state 2" and save that line. Then you save all following lines, adding them to the description, until you get a blank line.
Then when you get the blank line you switch to "state 3".
Then if you get an Exits line, this becomes "state 4".
Now if you got to state 4, you probably have a room change, yes?
So now you can concatenate it all together, eg.
"Within the Maze" ..
"Tall lusterous green hedges rise high above you, blocking your vision" ..
"from seeing over top of them. Hanging from metal posts, a lantern glows" ..
"brightly, lighting the crushed rocks beneath your feet. The hedges" ..
"themselves are well kept and neatly trimmed, but it matters not which way" ..
"you look for it all appears to be the same." ..
"[Exits: east south ]"
Then you take the md5 hash of all that (like I did in the other plugin) giving you a "room number". This can be used to drive the mapper.
Then you switch back to "state 0" (no room description yet) and wait for it all to happen again. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Ashass
(50 posts) Bio
|
Date
| Reply #2 on Fri 17 Dec 2010 03:45 AM (UTC) |
Message
| I was pondering in a more general sense of,
<movement>
[Start capture]
Line 1 (*) - assign as room name
Multiline (*) - assign as room desc
Line X ([Exits: * ]
[End Capture]
Then hash that, but I'm not exactly sure how to combine it in such a fashion, except maybe like this...
*\n*\n[Exits: *]
Except I don't know if the second * will actually capture the multi line room desc... | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Fri 17 Dec 2010 04:02 AM (UTC) |
Message
| Well triggers don't match what you send, so it won't match on the direction.
Secondly, you don't know how many lines before the exit, so the wildcard of the description and the newline is unlikely to match reliably.
I think my method is going to give more reliable results. Without reliable results it will mistake one room for multiple rooms, or vice-versa. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Ashass
(50 posts) Bio
|
Date
| Reply #4 on Fri 17 Dec 2010 04:18 AM (UTC) Amended on Fri 17 Dec 2010 04:22 AM (UTC) by Ashass
|
Message
| the problem is room names do not have to be the same color. (Typically) it's a cyan on black, and fairly reliable, but by no means is it 100% though.
But for now, to make things simple, lets vet out how you would write it.
Assuming it's a cyan on black color for room name, and next like is 2 spaces then the desc, how would you trigger off that?
<<roomname>> (colored)
desc (two spaces)
[Exits: * ] (one space)
***EDIT***
Also important to note, only the first line of the desc is indented two spaces, all lines after the first, but before exits are no spaces. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #5 on Fri 17 Dec 2010 04:47 AM (UTC) |
Message
| Well, have a look at the Materia Magica one:
https://github.com/nickgammon/plugins/blob/master/Materia_Magica_Mapper.xml
At around line 400, it processes the trigger for the room name (which is initially enabled). That starts the process off by remembering the name, and enabling the other triggers.
They basically save their stuff until the end of the description lines. Eventually various triggers disable other ones (or themselves) setting things up ready for next time.
Ashass said:
Also important to note, only the first line of the desc is indented two spaces, all lines after the first, but before exits are no spaces.
Well, you probably enable (on the room name line) a trigger that matches everything (ie. "*").
Then when that fires, you check if, the first time it fired you had two spaces at the start of the line. You know it is the first time because the description is currently empty.
Now the exits line trigger (which can probably be always enabled) then disables the "catch-all" trigger for the description lines. It checks that there was in fact any description received. If so, then it has something to work with.
|
- 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.
19,140 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top