|
GuinnessDNA Beginner
Joined: 12 Feb 2003 Posts: 23
|
Posted: Wed Mar 26, 2003 12:02 am
Trigger over multiple lines |
I have a database of messages I would like to have triggers for, there are about 390 (and growing) triggers I would like to respond to and this is how they work:
"Blow to the head causes the %1's ears to ring!"
and i use a #sub and replace it with
"Blow to the head causes the %1's ears to ring! Rank 0 Crush to Head, +5 Damage"
In my database each of those messages has a Rank, a Type (crush), a location and a Damage.
Is there an easy way to have the triggers respond to the database (instead of having 390 triggers, which seems to be limited to 254 to a folder anyway) and also some of the messages occur over multiple lines, for example:
"Blow to eye impacts the brain.
The critter twitches violently, then dies."
Is there a way to have my trigger ignore the carrage return? or a wildcard that represents the carrage return?
thanks. |
|
|
|
Dora Newbie
Joined: 27 Mar 2003 Posts: 2 Location: USA
|
Posted: Thu Mar 27, 2003 3:01 pm |
I'm wondering the same thing: Can a trigger match multiple lines?
|
|
|
|
Draxtier Newbie
Joined: 13 Mar 2003 Posts: 9 Location: Canada
|
Posted: Thu Mar 27, 2003 6:05 pm |
Yes, triggers can respond to multiple lines.
quote:
"Blow to eye impacts the brain.
The critter twitches violently, then dies."
Is there a way to have my trigger ignore the carrage return? or a wildcard that represents the carrage return?
Have {Blow to eye impacts the brain.$The critter twitches violently, then dies.} as your trigger pattern and it will match both lines.
To have zMUD intelligently reference the database is something beyond my expertise and likely something you'll need a guru to help with. I thought I'd do what I could though
blah |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Thu Mar 27, 2003 10:05 pm |
I don't think using the database is more efficient that create all of the triggers. Basically, you would need a trigger that matches every line and this trigger would loop through the database comparing the matched pattern agaisnt the stored pattern in the database using the =~ operator.
Kjata |
|
|
|
virtuous Wanderer
Joined: 08 Jan 2003 Posts: 60
|
Posted: Sun Mar 30, 2003 1:25 pm |
Too bad the matcher doesn't use wildcards stored in a list. Then you could put all of your patterns in a string list and have one trigger.
I wish you could do things like this...
^You take ({one|%d}) gold coin{|s}.$ |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Mar 30, 2003 2:44 pm |
There are ways around that. For example, you can match it with a pattern of:
^You take (%x) gold coin{|s}.$
and then do this in the trigger:
#IF ("%1" =~ "{one|%d}") {code here}
Kjata |
|
|
|
virtuous Wanderer
Joined: 08 Jan 2003 Posts: 60
|
Posted: Sun Mar 30, 2003 3:05 pm |
Do you mean that you can use wildcards in string lists with the =~ operator, even though you can't in the trigger itself? Like, I could use your %x trigger, with =~ matching {one|%d}, to catch both of the following types of lines?
You take one gold coin.
You take 5642 gold coins. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Mar 30, 2003 3:41 pm |
Oops, I wasn't thinking clearly there for a moment. What I meant to write is:
#IF (("%1" = "one") or ("%1" =~ "%d")) {code here}
Kjata |
|
|
|
virtuous Wanderer
Joined: 08 Jan 2003 Posts: 60
|
Posted: Sun Mar 30, 2003 5:20 pm |
Yes, that is excellent, making one trigger out of two. Thank you. :-)
|
|
|
|
|
|