|
trigger that match more then one line
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Avariel
Portugal (55 posts) bio
|
| Date |
Thu 05 Sep 2002 05:50 PM (UTC) [ quote
] |
| Message |
im trying to do this trigger to match 2 lines but im not being able to :(
ive tried \n and \r to match the new line but didnt work
tried with and without $ before and ^after the \n and \r but didnt work either way
i start wonder if thats possible.
can someone help me with that?
thx. |
The Avariel Wind Lord | top |
|
| Posted by |
Shadowfyr
USA (1,774 posts) bio
|
| Date |
Reply #1 on Thu 05 Sep 2002 08:28 PM (UTC) [ quote
] |
| Message |
Mushclient triggers don't match multilines. The only way to really do it is if the second line is indented or you can be sure that the last line will be followed by something unique, then you can use a 'capture' trigger and script to handle it.
In either case you set up a trigger that is 'trigger: *, sequence: 1, keep evaluating' and enable it when you get the first line, then disable it as soon as the wildcard return the unique line you are looking for, or is no longer indented. I had to do this for coloring channel traffic, where I wanted the result to be different than the standard ansi. |
main {
__if (Schrodinger_Cat is Alive or version >= "XP"){
____if version = "Vista" then Performance /= Number_of_Cores;
____call Functional_Code();}
__else
____call Crash_Windows();} | top |
|
| Posted by |
Avariel
Portugal (55 posts) bio
|
| Date |
Reply #2 on Fri 06 Sep 2002 04:11 PM (UTC) [ quote
] |
| Message |
ok thx for the sugestion...
i didnt know i couldnt match a multiline...
what i wanted to do is this:
'you eat a piece of meat.' --> eat again
'you eat a piece of meat.
you are full.' --> stop eat
what ive been doing is:
'you eat a piece of meat.' -> set var 'eat' 'yes'
'you are full.' -> set var 'eat' 'no'
'< *Hp *Mn *Mv>' -> if 'eat' = 'yes' eat again
this might be a twisted way of doing it :/ ill try your way. |
The Avariel Wind Lord | top |
|
| Posted by |
Shadowfyr
USA (1,774 posts) bio
|
| Date |
Reply #3 on Fri 06 Sep 2002 07:37 PM (UTC) [ quote
] |
| Message |
| Actually for that situation your method is what I would have done anyway. I use the multiline work around only in cases like reading all the herbs out of my inventory to use in my potion plugin, coloring channel traffic (which my mud insists on auto-wrapping and can be 3+ lines long) or other similar situations. In your case you have 3 unique instances and thus you can trap them individually without a problem. Multiline and the work around for not having it is only realy useful when you "don't" know what text is actually being captured, except for the line/command that starts it and some line that you know will end it. |
main {
__if (Schrodinger_Cat is Alive or version >= "XP"){
____if version = "Vista" then Performance /= Number_of_Cores;
____call Functional_Code();}
__else
____call Crash_Windows();} | top |
|
| Posted by |
Demokis
USA (8 posts) bio
|
| Date |
Reply #4 on Wed 30 Oct 2002 03:10 AM (UTC) [ quote
] |
| Message |
I'm having difficulty writing a script to handle triggering on multple lines, that I need is a script to capture one string then insert it when called by another trigger, I've had one before that was written for me but I lost it when I had to format after a serious crash, here is an example of what I want.
Triggered on :
A kobold is dead.
You recieve 200 experience points.
Ok I know how to make the trigger to report the experience gained. What I would like to know since I don't know the scripting language is how to make the output of the trigger on multiple lines read:
I gained 200 experience from the death of a Kobold.
to be completely honest I have no clue on how to write the script and any help would be appreciated. | top |
|
| Posted by |
Demonsurfer
USA (256 posts) bio
|
| Date |
Reply #5 on Wed 30 Oct 2002 03:32 AM (UTC) [ quote
] |
| Message |
hmm.. you could have one line to set a variable so that the message of
"A kobold is dead."
would match on a trigger of
"A * is dead."
and that trigger would then call a subroutine (called 'dead' for example) which would set the variable..
sub dead (thename, theoutput, thewildcards)
World.SetVariable "dead", thewildcards (1)
end sub
the next message of
"You recieve 200 experience points."
would match a trigger of
"You receive * experience points."
which could send, for example
grouptell I gained %1 experience from the death of a @dead.
or if you wanted it as a note for yourself only, this second trigger could call another subroutine (called 'report' for example) to world.note it..
sub report (thename, theoutput, thewildcards)
dim mob
dim exp
mob = World.GetVariable("dead")
exp = thewildcards (1)
World.Note "I gained "& exp &" experience from the death of a "& mob &"."
end sub
does that help? | top |
|
| Posted by |
Demonsurfer
USA (256 posts) bio
|
| Date |
Reply #7 on Wed 30 Oct 2002 03:50 AM (UTC) [ quote
] |
| Message |
| heh kewl :) looks like I suggested the same thing as Nick did, with the addition of the world.note script.. I can stop holding my breath now. | top |
|
| Posted by |
Nick Gammon
Australia (18,770 posts) bio
Forum Administrator |
| Date |
Reply #8 on Wed 30 Oct 2002 05:08 AM (UTC) [ quote
] |
| Message |
Actually, you can do it without scripting. One trigger sends the monster name to a variable, the other one uses that variable. Like this:
<triggers>
<trigger
enabled="y"
match="A * is dead."
name="monster"
send_to="9"
sequence="100"
>
<send>%1</send>
</trigger>
<trigger
enabled="y"
expand_variables="y"
match="You recieve * experience points."
send_to="2"
sequence="100"
>
<send>I gained %1 experience from the death of a @monster.
</send>
</trigger>
</triggers>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
| Posted by |
Demonsurfer
USA (256 posts) bio
|
| Date |
Reply #9 on Wed 30 Oct 2002 05:57 AM (UTC) [ quote
] |
| Message |
| hah! sweeeeet. I've been using scripts for setting all my variables, which are many. you've just saved me a lot of unneccessary work. :) thanks Nick | top |
|
| Posted by |
Demonsurfer
USA (256 posts) bio
|
| Date |
Reply #10 on Wed 30 Oct 2002 07:27 AM (UTC) [ quote
] |
| Message |
| hmm.. any chance you can add the ability to do this with aliases as well? (set variables with an alias without having to call a script do it) | 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.
2,297 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )