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


Joined: 19 Mar 2004
Posts: 9
Location: Canada

PostPosted: Fri Mar 19, 2004 8:05 am   

Capturing multiple lines into a variable.
 
I'm playing on Godwars: Saint from Shadows...

I'm attempting to create a help database, for the purpose of displaying all the help files locally once its completed.

My dillemma...

---- SAMPLE OUTPUT ----
<[31997584] [45532H 45532M 45532V]> help monk

-=[**]=-=[**]=-=[**]=-=[**]=-=[ MONK ]=-=[**]=-=[**]=-=[**]=-=[**]=-

Afters hundreds of years of living in solitude these quiet
warriors have taken it upon themselves to rid the world of
all evil. Unable to use any weapons they are able to use
their hands as well as any sword or axe. It is said, to
stare at an enraged monk is to stare into death's eyes
themself.

Mantra - Used to gain powers.
Technique - Used to learn your attacks
Training - Used to gain combos.
Hum - Class channel.
Monkarmor - Create powerful armor.

Also see HELP MANTRA

-=[**]=-=[**]=-=[**]=-=[**]=-=[ MONK ]=-=[**]=-=[**]=-=[**]=-=[**]=-

<[31997584] [45532H 45532M 45532V]> _
---- SAMPLE OUTPUT ----

What I'd like a trigger to do:

I type: capturehelp <keyword>
which activates the capturing, and sends ~help <keyword> to the mud.

Variable HEADER stores: MONK
Variable BODY stores: all lines after capturehelp <keyword> is typed until the next prompt.

At this point, I can handle it, but i just can't get a trigger to store consecutive lines into a variable.

My attempt:
#CLASS {HelpCapture|Starter}
#TRIGGER {^-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[(*)]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-$} {#T- {HelpCapture|Starter};#T+ {HelpCapture|Body};#VAR HelpCapture_Body;#VAR HelpCapture_Starter %lower(%trimleft(%trimright(%1)))}
#CLASS {0}
#CLASS {HelpCapture|Body}
#TRIGGER {(*)} {ADDITEM @HelpCapture_Body %0}
#TRIGGER {^-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[ * ]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-$} {#T- {HelpCapture|Body};#ADDKEY Header @HelpCapture_Starter;#ADDKEY Body @HelpCapture_Body}
#CLASS {0}
#ALIAS chelp {#T+ HelpCapture|Starter;#VAR HelpCapture_Starter %lower(%1);~help %1}

My Attempt seems to only place a "return" character into the body,
the starter variable fills properly. And nothing happens to the open database...

Database Name: Help
Fields:
Header -text
Body -memo

Number of records: %null


--------------------------------------------------
Any feedback would be MOST appreciated. Yes I have
checked the forums for similar topics, but I could find
nothing like this anywhere.
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Fri Mar 19, 2004 11:14 am   
 
For a start, you don't have an @ with Additem command, and you've forgotten the command char, default #.

#CLASS {HelpCapture|Starter}
#TRIGGER {^-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[(*)]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-$} {#T- {HelpCapture|Starter};#T+ {HelpCapture|Body};#VAR HelpCapture_Body {%null};#VAR HelpCapture_Starter {%lower(%trimleft(%trimright(%1)))}}
#CLASS 0
#CLASS {HelpCapture|Body}
#TRIGGER {(*)} {#ADDITEM HelpCapture_Body {%1}}
#TRIGGER {^-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[ * ]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-$} {#T- {HelpCapture|Body};#ADDKEY Header @HelpCapture_Starter;#ADDKEY Body @HelpCapture_Body}
#CLASS 0
#ALIAS capturehelp {#T+ HelpCapture|Starter;~help %1}
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Mar 19, 2004 7:47 pm   
 
Additional problems.
1. #ADDKEY requires three parameters: VariableName, Key, and Value. You only have two.
2. The script doesn't open the database (this is okay as long as you open the database manually). Database commands only work when the database module is in memory, and it's only in memory when a database is open, so it's best to just open the database and leave it open. If you will have more than one database, use #DBLOAD to select the desired database before adding records.
3. Your script doesn't include the #NEW command, which is used to create new database records.
4. The MEMO field-type is "multiple lines of text". It would probably be better to make the corresponding variable, @HelpCapture_Body, a string rather than a list.
5. You set the value of @HelpCapture_Starter in the alias, and then again in your first trigger. The value from the trigger will overwrite the value from the alias, so the alias doesn't need the #VAR command.
6. %trim() will do the same thing as %trimleft( %trimright()). However, %lower will remove the leading and trailing spaces anyway, so even %trim isn't needed.
7. #VAR varname just displays the value of the variable, it doesn't change it. Use %null, "", or {} to clear a variable.

#CLASS {HelpCapture|Starter}
#TRIGGER {^-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[(*)]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-$} {#T- {HelpCapture|Starter};#VAR HelpCapture_Body {};#VAR HelpNew {};#T+ {HelpCapture|Body};#VAR HelpCapture_Starter {%lower( %1)}}
#CLASS {0}
#CLASS {HelpCapture|Body}
#TRIGGER {(*)} {#IF %len( @HelpCapture_Body) {#VAR HelpCapture_Body {@HelpCapture_Body%{crlf}%1}} {#VAR HelpCapture_Body {%1}}}
#TRIGGER {^-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[ * ]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-=~[~*~*~]=-$} {#T- {HelpCapture|Body};#ADDKEY HelpNew Header {@HelpCapture_Starter};#ADDKEY HelpNew Body {@HelpCapture_Body};#NEW All @HelpNew}
#CLASS {0}
#ALIAS chelp {#T+ HelpCapture|Starter;~help %1}
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