About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Majnun
Newbie


Joined: 25 Apr 2004
Posts: 9

PostPosted: Sun Apr 25, 2004 5:18 am   

NEWB: Room descriptions in seperate window?
 
I'm starting to get tired trying to figure this out, and i'm sure there must be a simple solution.

When I enter a room, or send the MUD the look command, I want to capture the room name and description and send it to another window.

Text from MUD on entering room or typing look:

The Ring of Portals.
You have a strong sense that READ SIGN would be a good idea. A sign floats above the ground here. There are 8 pieces of bayberry bark in a group here. A ball of myrrh gum resides here. Karalt is here. He wields a steel shortsword in his left hand. Acolyte Baldorn is here. He wields a steel shortsword in his left hand. Shracke is here. He wields a steel shortsword in his left hand.
You see exits leading north, southeast, south, southwest, and northwest.
448h, 484m, 1140e, 1320w e-

(The last line is the prompt)


Any help is greatly appreciated thanks!
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Apr 25, 2004 5:44 am   
 
*ponder* off the top of my head the EASIEST way would be to use the mapper then use the onroomenter alias to :descwindowname:#say %roomname %cr %roomdesc

OR if your room desc/title is/can be changed to a unique color you can use an ansi trigger to capture all lines colored that color to the window.
Highlight the first line of your desc goto the settings editor and make a new trigger, go to the options tab and select the ansi color option go back to the patterns tab and CTRL-Insert

you should end up with something like this for the pattern
%e[37mthis is the first line of the desc
chang it so its something like this
^%e[37m*

and for the pattern
#cap roomwindowname

do the same thing for your room titleand you should be set (might require tweaking)
Reply with quote
Majnun
Newbie


Joined: 25 Apr 2004
Posts: 9

PostPosted: Sun Apr 25, 2004 6:13 am   
 
Ok, that works for me.

Bonus Questions:

1) How can I clear the current text from a window before #CAP to it?

2) If for some reason playing a game without ansi colors for room titles, is possible to do without resorting to mapper, since sometimes that might not be accurate / i'm running thru unmapped terrain.

Thanks!
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Apr 25, 2004 6:47 am   
 
The mapper is the best way to go. It works by detecting the only really triggerable item in a room, the exit line. Then either looking forward or backward to find the name and description. The scripting language only gives you 2 previous lines to play with directly; while the mapper can literally can go all the way to the beginning of the scroll back buffer. Two lines might work for some descriptions but not all. So the solutions for unmapped terrain are map it or maintain your own scroll back buffer then parse it out like the mapper does.

To clear a window before #CAP you can use ":windowName:#SAYP %char(27)[2J" or ":windowName:#MENU {Layout|Clear Window}"
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Apr 25, 2004 6:00 pm   
 
Or
:windowName:#CLR
Reply with quote
Majnun
Newbie


Joined: 25 Apr 2004
Posts: 9

PostPosted: Mon Apr 26, 2004 7:17 am   
 
Great!

Cool!

This begs a question in my mind:

What is the logic that the mapper actually uses to figure out what the name of the room is, what the description is, and what the exists are? Can that logic be duplicated using triggers so I can capture the data?

I guess I want to use the power of the mapper's logic in parsing without having to rely on the accuracy of its database- for example, in my MUD the room descriptions are constantly changing to represent weather conditions and wandering mobs etc.

Thank you all for your help!
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Mon Apr 26, 2004 2:14 pm   
 
Like Vigilante said
quote:
The mapper is the best way to go. It works by detecting the only really triggerable item in a room, the exit line. Then either looking forward or backward to find the name and description. The scripting language only gives you 2 previous lines to play with directly; while the mapper can literally can go all the way to the beginning of the scroll back buffer. Two lines might work for some descriptions but not all. So the solutions for unmapped terrain are map it or maintain your own scroll back buffer then parse it out like the mapper does.


The mapper triggers off the exits/prompt/blankline line and goes backwards/forwards from there. About the only easy way to capture roomnames/descs outside of the mapper would be with ANSI color triggers.
Reply with quote
Majnun
Newbie


Joined: 25 Apr 2004
Posts: 9

PostPosted: Mon Apr 26, 2004 4:45 pm   
 
Right, I guess saying is:

I'd like to emulate the logic of the mapper...

I know how to find the exists, that's a relatively straight forward regular expression... but what is the logic that mapper uses to go backward and find where the room name?

My assumption is it uses some kind of comparison logic to get the data, and I would like to write my own trigger function that does the same thing.

Is the main stumbling block that the #CAP doesn't "scroll" back enough?
Reply with quote
Majnun
Newbie


Joined: 25 Apr 2004
Posts: 9

PostPosted: Mon Apr 26, 2004 4:50 pm   
 
Oh, sorry didn't read response carefully enough (so much for my multitasking ability):

quote:
So the solutions for unmapped terrain are map it or maintain your own scroll back buffer then parse it out like the mapper does.


Whats the best way to maintain a scroll back buffer?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Apr 26, 2004 10:02 pm   
 
I would suggest using on #ONINPUT trigger with pattern of {^%t$} to detect you sent a movement and clear your buffer. Then a second state (#CONDITION use Looplines blank pattern) to capture the text (list of lines should work well) with checking by %regex for the exitline. Once the exitline is detected change to another #STATE (use Manual and #SET to activate) then start your parsing. First work backwards for a blank line, the next line is name, and everything else is description. Simply put it into another variable and %replace the "|" with %cr then #WINDOW it over.

Probably took me longer to write the above then it would have to do the script, but you will learn more this way.
Reply with quote
Majnun
Newbie


Joined: 25 Apr 2004
Posts: 9

PostPosted: Mon Apr 26, 2004 11:31 pm   
 
Ok, I've figured out how to do what I wanted, thank you all for you help. For others with similar wishes here's what I did:

All this script works with output like:

Ivy-covered archway to Minia.
Small flakes of white float through your field of vision here and there. Vellis, the butterfly collector potters about nearby. A shimmering blanket of shadowy rose petals is laid out here, scenting the area. There is a small group of sprigs of cactus weed here. Wyrm Kyvinn, Orophin's Breaking Dawn is here. He wields an iron-tipped whip in his left hand and a needled-pointed dirk in his right. Thamior, Novitiate Third is here. He wields a steel shortsword in his left hand. Puppet Allie, the Shaman Novice is here. She wields a hefty shovel in her left hand.
You see exits leading northeast, east, southeast, and south.

448h, 484m, 1140e, 1320w ex-

(First line is room title ANSI Yellow, last line is prompt. Note: this works even if inside the room description is a string that looks just like your Room Title because it ignores things once it gets rolling until it comes to the prompt)




Step1) Creat Trigger for Room Title (in my case it was a color that i was looking for, since the MUD has mostly unique color for Room Title) Note: the use of the #IF command because supposing you accidentally find the pattern in the room, you don't want to recur the process and capture a partial room description)

Pattern(This should be the pattern for the first line of room output - here - a newline starting with ANSI YELLOW):
^%e[33*

Value:
;skip this if the RoomCapture class is already open
#IF %class( RoomCapture) {#NOOP} {
#T+ RoomCapture
#CLR Room
}




Step 2) Create the RoomCapture Class

Name:
RoomCapture




Step 3) Create a catchall trigger and PUT it INSIDE of the RoomCapture Class:

Pattern:
*

Value:
#CAP Room
#GAG




Step 4) Create a trigger to close the Class (do NOT put it in the class) The pattern should be your prompt! (Note: the () in the pattern is because I am using this trigger for other things than just closing the class.)

Pattern(here - my prompt):
(%d)h, (%d)m, (%d)e, (%d)w (*)

Value:
;turn off the RoomCapture class
#T- RoomCapture




The general principles here are these: to capture multiple lines of output you need to set a trigger to clear the capturing window and open a class which has a trigger which catches everything, and then another trigger (usually a prompt or other unique line) which closes that class (so it stops capturing). And if your starting trigger isn't 100% unique, you will want to skip doing anything if the class is still open.

Hope that helps others who wanted to do similar things!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net