Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ trigger that match more then one line

trigger that match more then one line

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Avariel   Portugal  (55 posts)  Bio
Date Thu 05 Sep 2002 05:50 PM (UTC)
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,788 posts)  Bio
Date Reply #1 on Thu 05 Sep 2002 08:28 PM (UTC)
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.
Top

Posted by Avariel   Portugal  (55 posts)  Bio
Date Reply #2 on Fri 06 Sep 2002 04:11 PM (UTC)
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,788 posts)  Bio
Date Reply #3 on Fri 06 Sep 2002 07:37 PM (UTC)
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.
Top

Posted by Demokis   USA  (8 posts)  Bio
Date Reply #4 on Wed 30 Oct 2002 03:10 AM (UTC)
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 Guest1   USA  (256 posts)
Date Reply #5 on Wed 30 Oct 2002 03:32 AM (UTC)
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 Demokis   USA  (8 posts)  Bio
Date Reply #6 on Wed 30 Oct 2002 03:48 AM (UTC)
Message
Actually after looking around for a while and looking at my bio my original request was there. with the solution and I have it working perfectly once again. Here is the string:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=73
Top

Posted by Guest1   USA  (256 posts)
Date Reply #7 on Wed 30 Oct 2002 03:50 AM (UTC)
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  (23,120 posts)  Bio   Forum Administrator
Date Reply #8 on Wed 30 Oct 2002 05:08 AM (UTC)
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 Guest1   USA  (256 posts)
Date Reply #9 on Wed 30 Oct 2002 05:57 AM (UTC)
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 Guest1   USA  (256 posts)
Date Reply #10 on Wed 30 Oct 2002 07:27 AM (UTC)
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.


29,131 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.