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


Joined: 18 Oct 2002
Posts: 6
Location: USA

PostPosted: Sat Feb 01, 2003 8:11 am   

Capturing the prompt and room description
 
I'm working on part of this script. The function it should perform is to capture the text after a flee command and display using the #show command. Here's the code.

#KEY DIV {flee;#VAR captTxt "";#T+ textCapture};
#CLASS {textCapture} {disable};
#TRIGGER {^(*)$} {captTxt = %additem( %1, @captTxt)};
#TRIGGER {^~[ obvious exits: * ~]$} {#T- textCapture;#FORALL @captTxt {#SHOW %i}};
#CLASS 0

When I triggered the script by fleeing, %additem() evaluates any comma in the text captured. Then I tried capturing each line and concatenating them, same thing happened. Then I wrapped %1 with expand characters "<>", but nothing changed.

Is there any way I can get around the comma problem? I thought about capturing the text between the commas. But I can't figure out the expression for the pattern to match. :(
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Sat Feb 01, 2003 8:36 am   
 
When using %1 in functions or commands it is best to encapsulate it with "quotes" or {braces} respectively. So all you should have to do is change it thusly:
%additem( "%1", @captTxt)}
Reply with quote
sybatter
Newbie


Joined: 18 Oct 2002
Posts: 6
Location: USA

PostPosted: Sat Feb 01, 2003 8:40 am   
 
Yup. It worked as predicted now. Thanks.
Reply with quote
sybatter
Newbie


Joined: 18 Oct 2002
Posts: 6
Location: USA

PostPosted: Sat Feb 01, 2003 8:44 am   
 
While we are at it, is there any other way to capture the text using a different trigger pattern? Any way to match the phrases between the commas? A difficulty to achieve this I've faced is that the trigger reads line by line. So if I use the pattern (*),, and a line does not have a comma, it does not capture the text. Any way to fix it?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Feb 01, 2003 6:09 pm   
 
As near as I can tell, you are just capturing the entire room description and then displaying it with #SHOW. The easiest way to do this would be to just turn off gagging and let the MUD's original room description come through.

LightBulb
Advanced Member
Reply with quote
sybatter
Newbie


Joined: 18 Oct 2002
Posts: 6
Location: USA

PostPosted: Sun Feb 02, 2003 12:37 am   
 
Yeah. That's another solution to the problem as well. So now I've successfully captured text from the MUD using this script. Next I want to isolate the room description to a new variable, so I can use the description to match the room in the map database. What this would do is, after I flee, I am able to locate where I fled to without reloading the room.

Before doing that though, I used the #SHOW command and tested whether the room description has been successfully filtered. However it seems it did not catch either the prompt or the room description. Here's the code. Any idea what went wrong?

#KEY DIV {flee;#VAR captTxt "";#T+ RoomTracer}
#CLASS {RoomTracer} {disable}
#TRIGGER {^(*)$} {captTxt = %additem( "%1", @captTxt)}
#TRIGGER {^~[ obvious exits: * ]$}
{#T- RoomTracer;#FORALL @captTxt {#IF (%i =~ "(? HP:%w MV:%w >)") {prompt = %1}};newList = %delete( @captTxt, 1, %pos( "@prompt", @captTxt));#FORALL @newList {#SHOW %i}}
#CLASS 0

FYI this code does not actually match anything from the map database. I skipped that part to get to the main problem which is, how come the script does not filter the prompt and the room description?
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