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
dracx
Beginner


Joined: 14 Oct 2000
Posts: 26
Location: USA

PostPosted: Fri Mar 01, 2002 7:15 pm   

HARD problem! (long post)
 
Here's the scenario....

I have a 'health' command, and here's what it looks like:

>Health
Your body feels at full strength.
Your spirit feels full of life.
You have a few nearly invisible scars along the head, a few nearly invisible
scars along the neck, a few nearly invisible scars along the right arm, a few
nearly invisible scars along the left arm, a few nearly invisible scars along
the right leg, a few nearly invisible scars along the left leg, a few nearly
invisible scars along the right hand, a few nearly invisible scars along the
left hand, a few nearly invisible scars along the chest, a few nearly
invisible scars along the abdomen, a few nearly invisible scars along the back, minor scars across the right eye, some tiny scratches to the left eye, some
tiny scars across the left eye.

And here's what I WANT it to look like:

>Health
Your body feels at full strength.
Your spirit feels full of life.
You have a few nearly invisible scars along the head
a few nearly invisible scars along the neck
a few nearly invisible scars along the right arm
a few nearly invisible scars along the left arm
a few nearly invisible scars along the right leg
a few nearly invisible scars along the left leg
a few nearly invisible scars along the right hand
a few nearly invisible scars along the left hand
a few nearly invisible scars along the chest
a few nearly invisible scars along the abdomen
a few nearly invisible scars along the back
minor scars across the right eye
some tiny scratches to the left eye
some tiny scars across the left eye

-----------------------

Now, obviously, the wounds aren't always the same, and therefore, neither is the length of the paragraph that contains them. I guess what we are going for here is everything in between the punctuation marks in the first paragraph, and then we wanna toss out those triggers so it doesn't step on the rest of the mud output.

Here's what I've got so far...

#TRIGGER {(*)$} {#VARIABLE wounds {%additem( %%1, @wounds)} {Wound List}}
#TRIGGER {You have} {#TEMP {.$} {#UNTRIGGER {(*)$}}}

However, this isn't adding the items to the woundlist properly, so I can't even begin to parse this correctly... I'm starting to wonder if I should write a plugin to do this instead of trying to use the scripting language in zmud...

If anyone can solve this problem for me, I'd really appreciate it, as would a lot of people in my mud.

Drac-X
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Fri Mar 01, 2002 7:32 pm   
 
The following can be used in "detecting" it. I wonder if you can get it all on
one line to simplify things. For now I'll just assume you can't.

Your body feels at full strength.
Your spirit feels full of life.
You have a few nearly invisible scars along the head, a few nearly invisible
scars along the neck, a few nearly invisible scars along the right arm, a few
nearly invisible scars along the left arm, a few nearly invisible scars along
the right leg, a few nearly invisible scars along the left leg, a few nearly
invisible scars along the right hand, a few nearly invisible scars along the
left hand, a few nearly invisible scars along the chest, a few nearly
invisible scars along the abdomen, a few nearly invisible scars along the back, minor scars across the right eye, some tiny scratches to the left eye, some
tiny scars across the left eye.

Furthermore you can hack into the word health.

Capture when you enter health, toggle the classfolder to capture the health and then
manually send it to the mud:
#ALIAS health {#T+ healthcapture;#SEND health}

Capture the Your body and Your spirit lines to verify we have the health and toggle
the classfolder to capture the wounds:
#TRIGGER {^Your body (%*).$Your spirit (%*).$} {#NOOP need %1 and %2?;#T+ healthwoundcapture;#VAR wounds ""} "healthcapture"

Capturing lines of wounds, gag them, add it all to 1 sentence @wounds,
till we see a period:
#TRIGGER {^(%*)$} {#GAG;#VAR wounds %concat(@wounds,"%1"," ");#IF ( %copy("%1",%len("%1"),1) =~ ".") {#T- healthwoundcapture;do_show_wounds}} "healthcapture|healthwoundcapture"

Show us what was found:
#ALIAS do_show_wounds {#VAR wounds %replace(@wounds,",","|");#FORALL @wounds {#SAY %i};#T- healthcapture} "healthcapture"

Off the cuff but conceptually right.


TonDiening
Beta Upgrading to 6.26
Reply with quote
dracx
Beginner


Joined: 14 Oct 2000
Posts: 26
Location: USA

PostPosted: Fri Mar 01, 2002 8:56 pm   
 
Hang in with me for a sec please :)
First off, your use of functions is a little advanced for me, so I'm not going to pretend to follow everything exactly. With that said.... Here's what I have...

(*note, since you wrote this off the cuff, there were a few syntactical errors that I tried to correct, but I'm not sure I did it right. The way you posted originally, I was gagging all of the mud text after execution of the 'health' alias, and I'm pretty sure you didn't intend that :) Anyway, this is NOT exactly the code you originally posted, but it is close)

#ALIAS {health} {#SEND health;#T+ healthcapture}
#CLASS {healthcapture}
#ALIAS do_show_wounds {
#VARIABLE wounds %replace( @wounds, ",", "|")
#FORALL @wounds {#SAY %i}
#T- healthwoundcapture
#T- healthcapture
#VARIABLE wounds ""
}
#TRIGGER {^Your body (%*).$Your spirit (%*).$} {
#NOOP need %1 and %2?
#T+ healthwoundcapture
#VARIABLE wounds ""
}
#CLASS 0
#CLASS {healthcapture|healthwoundcapture}
#TRIGGER {^(%*)$} {
#GAG
#VARIABLE wounds {%concat( @wounds, %1, " ")}
#IF ( %copy( %1, %len( %1, 1) =~ ".$")) {
#T- healthwoundcapture
do_show_wounds
}
}
#CLASS 0


And here is is the value of 'wounds':

Variable: wounds
> Clanna gestures. There is a brief white glow as Clanna's spell joins the protection spell already around her. Clanna bows her head and chants a prayer. >Your body feels at full strength. Your spirit feels full of life. You have a few nearly invisible scars along the heada few nearly invisible scars along the necka few nearly invisible scars along the right arma few nearly invisible scars along the left arma few nearly invisible scars along the right lega few nearly invisible scars along the left lega few nearly invisible scars along the right handa few nearly invisible scars along the left handa few nearly invisible scars along the chesta few nearly invisible scars along the abdomena few nearly invisible scars along the backminor scars across the right eyesome tiny scars across the left eye. > Yavash slowly rises above the horizon. > Rorie works carefully at tending her wounded back. > Jacko's right hand wounds look better. > Clanna gestures. Clanna bows her head and chants a prayer.


Now, as you can see, the trigger grabbed text ahead of the health response. Also, it grabbed text beyond the end of the health response and did not seperate the message in to items on a list. As a result (I think), the do_show_wounds alias isn't working properly either... but I'm only guessing at it's cause.

I'll kiss your feet if you can work this out :)

Drac-X
Reply with quote
Stryfe
Wanderer


Joined: 16 Oct 2000
Posts: 50
Location: USA

PostPosted: Fri Mar 01, 2002 10:21 pm   
 
Hmm.. here's what I came up with:

#CLASS {HealthCapture} {disable}
#TRIGGER {^Your body (%*).$Your spirit (%*).$} {#NOOP need %1 and %2?}
#TRIGGER {You have (*)} {#T+ healthwoundcapture;#gag;#var wounds %1}
#CLASS 0

#CLASS {HealthCapture|HealthWoundCapture} {disable}
#TRIGGER {^(*)$} {#gag;#var tempstw "%1";#var wounds %concat( @wounds, " ", @tempstw)}
#TRIGGER {^(*).$} {#T- HealthWoundCapture;do_show_wounds}
#CLASS 0

I left the 'body' and 'spirit' triggers just in case you need to capture those.

The {You have(*)} trigger is what turns on the healthwoundcapture class, to make sure DR lag doesn't screw you up. It's not going to start capturing text until it sees that line.
I'm pretty sure the wounds description always start with You have ... including "You have no significant injuries."

The trigger {^(*)$) captures all the wounds description. I used a temp variable because I find that if I don't, all the commas somehow.. um.. disappear. Anyone knows why?

The trigger {^(*).$} turns off the capture. There's probably a more efficient way to do this, but this work for me, so I keep using it.

I tested the above triggers with the do_show_wounds alias and it works, with minor spacing issue which can be fixed by using one of the %trim functions with the #SAY %i line. Oh, and it doesn't have the "You have" in front of the first wound description.. but that's easy enough to fix if you really want it.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Mar 02, 2002 12:17 am   
 
Hrm never been a fan of the multiline in single trigger thing. Anyhow I will base what I am going to write off Ton's code since he is a smart cookie.

#AL health {#T+ HealthCapture;TempHealthData=-1;#SEND health}
Stick with that order because since the 6.25 beta timing problems have occured. When Zugg finally found them everyone seemed to agree they were a good thing.
#CLASS HealthCapture
#VAR TempHealthData {-1}
#VAR Wounds {}
#TR {^Your body feels (*).} {#NOOP that health.}
#TR {^Your spirit feels (*).} {Wounds="";#T+ HealthCap2;#NOOP this health.}
#CLASS 0
#CLASS HealthCap2
#TR {^&*{TempHealthData}$} {
#GAG
#NOOP I am spreading this out so I make fewer typos with braces and paranthesis.
#IF (%ends(@TempHealthData,".") {
Wounds=%concat(@Wounds, %leftback(@TempHealthData,1)
Wounds=%replace(@Wounds,", ",%char(13))
Wounds=%remove("You have ", @Wounds)
#ECHO @Wounds
#T- HealthCap2
#T- HealthCapture
} {
#NOOP don't know if your muds word wrap strips the spaces or not so I will check for em.
#IF (!%ends(@TempHealthData," ") {
Wounds=%concat(@Wounds,@TempHealthData," ")
} {
Wounds=%concat(@Wounds,@TempHealhData)
}
}
}
#CLASS 0

Opps just noted your spec called for the "You have" to be left on, just dig that line out. Or just fix Ton's work...the offensive line appears to be this one in the ^(%*)$ trigger.

#IF ( %copy( %1, %len( %1, 1) =~ ".$")) {

It should be written as:
#IF ( %copy( %1, %len( %1, 1) = ".")) {
or
#IF ( %copy( %1, %len( %1, 1) =~ ".")) {
Mainly the problem with how it reads now is it is running a pattern match on the last character of the variable and checking that for the period we want and a newline. Doing the comparison by pattern match instead of exact match is fine, but it will never match the newline signified by the $. Just a minor logic flaw, the bane of all programmers.
Reply with quote
Reddytedy
Apprentice


Joined: 13 Oct 2000
Posts: 114
Location: USA

PostPosted: Sat Mar 02, 2002 3:29 am   
 
dracx I know your playing DR..you 'could' enable the gsl tags so the lines won't be wrapped and do many many many things with those tags. to enable em just type (case-sensitive) FeStArT and hit enter.. that will make the DR server send the stuff to you without breaking up the lines.. room descs will be on one line so will wounds and inventory and most other list type items.

Only thing is you're gonna have a rather large amount of #GAGs and #SUB lines. If you want I can show you my triggers I use with DR when I play using zMUD that will create hand buttons along with exits, posistion, status and There are GS Tags that tell you when and where and how bad you are bleeding. Still deciphering those.

Alan

Come play with us in Dragonrealms

http://www.play.net/dr
Reply with quote
itsmarty
Novice


Joined: 29 Jan 2002
Posts: 37
Location: USA

PostPosted: Sat Mar 02, 2002 3:56 am   
 
quote:

dracx I know your playing DR..you 'could' enable the gsl tags so the lines won't be wrapped and do many many many things with those tags. to enable em just type (case-sensitive) FeStArT and hit enter.. that will make the DR server send the stuff to you without breaking up the lines.. room descs will be on one line so will wounds and inventory and most other list type items.

Only thing is you're gonna have a rather large amount of #GAGs and #SUB lines. If you want I can show you my triggers I use with DR when I play using zMUD that will create hand buttons along with exits, posistion, status and There are GS Tags that tell you when and where and how bad you are bleeding. Still deciphering those.

Alan

Come play with us in Dragonrealms

http://www.play.net/dr



Thanks,
Martin
Reply with quote
Kru
Beginner


Joined: 14 Nov 2001
Posts: 28

PostPosted: Sat Mar 02, 2002 6:43 am   
 
Yeah, you should enable GSx when playing DR. It can turn the really complicated thing that Ton and Vigilante are trying to do to into this:

#TR {You have (*)} {#SUB {You have:%char(10)%replace("%1",",",%char(10))%char(10)%char(10)-------------};#VAR woundlist %replace("%1",",","|")}


Or.. If you don't like creating woundlist by hand, you can use #additem with a loop like #LOOP %numwords("%1",",") {#ADDITEM woundlist %word("%1",%i,",")}

My empath bot > yours. Wahaaa
:)
Reply with quote
starlight
Newbie


Joined: 05 May 2002
Posts: 0

PostPosted: Wed Apr 03, 2002 2:48 am   
 
quote:
dracx I know your playing DR..you 'could' enable the gsl tags so the lines won't be wrapped and do many many many things with those tags. to enable em just type (case-sensitive) FeStArT and hit enter.. that will make the DR server send the stuff to you without breaking up the lines.. room descs will be on one line so will wounds and inventory and most other list type items.


Is that string the same for gemstone 3? Also, is there anywhere that explains what the command strings are..? like what #TR {You have (*)} {#SUB {You have:%char(10)%replace("%1",",",%char(10))%char(10)%char(10)-------------};#VAR woundlist %replace("%1",",","|")} means? thanks
Reply with quote
starlight
Newbie


Joined: 05 May 2002
Posts: 0

PostPosted: Wed Apr 03, 2002 2:49 am   
 
quote:
dracx I know your playing DR..you 'could' enable the gsl tags so the lines won't be wrapped and do many many many things with those tags. to enable em just type (case-sensitive) FeStArT and hit enter.. that will make the DR server send the stuff to you without breaking up the lines.. room descs will be on one line so will wounds and inventory and most other list type items.


Is that string the same for gemstone 3? Also, is there anywhere that explains what the command strings are..? like what #TR {You have (*)} {#SUB {You have:%char(10)%replace("%1",",",%char(10))%char(10)%char(10)-------------};#VAR woundlist %replace("%1",",","|")} means? thanks
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