|
Saffire Newbie
Joined: 09 Aug 2002 Posts: 3
|
Posted: Fri Aug 09, 2002 8:44 pm
Multiple instances |
Hey all,
I'm kinda new to this, so probably this has been answered already..
How would you set zMUD up to trigger multiple instances on one line
Lets say that my trigger should add one to var blah everytime blah shows up
So
Blah dfds Blah dfdsfs Blah fdsfs Blah
Should give a value of 4, but I can't figure out how to do this
Thanks :) |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Aug 09, 2002 11:05 pm |
#TR {blah} {#VAR TempCounter %trigger;#WHILE (%pos("blah",@TempCounter) {#ADD blah 1;TempCounter=%remove("blah",@TempCounter)}}
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Aug 09, 2002 11:55 pm |
Why would anyone bother counting "blah"'s? Just move to a more interesting MUD!
Is there any good reason to conceal what you actually want to count?
Anyway, something like this should do it.
#TR {blah} {#MATH blah {%if(%begins({%trigger},"blah"),1,0) + %if(%ends({%trigger),"blah"),1,0) + %numwords({%trigger},"blah") - 1}
LightBulb
Senior Member |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Aug 10, 2002 12:13 am |
I like Lightbulb's better, of course he has a few typos and I can shorten it a little.
#TR {blah} {#MATH blah {%begins({%trigger},"blah") + %ends({%trigger},"blah") + %numwords({%trigger},"blah") - 1}}
The is no accounting for taste, blah that is bad. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sat Aug 10, 2002 3:33 pm |
Typos? I don't see any. But you're right, %if isn't needed. Nice.
AHA! I did find one
LightBulb
Senior Member |
|
|
|
Saffire Newbie
Joined: 09 Aug 2002 Posts: 3
|
Posted: Mon Aug 12, 2002 4:01 pm |
Err, I was just too lazy to type it out at first
What I really want to do is to execute a command whenever a certain pattern comes up
So basically the pattern would be :
Name1.......[213]
No given amount of periods, and this could happen multiple times on a line
Name1....[121] Name2...[1] Name3...[34]
Lets say I want to 'whois %1' everytime I see this, how would I go about doing this? |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Aug 12, 2002 10:28 pm |
quote:
Err, I was just too lazy to type it out at first
What I really want to do is to execute a command whenever a certain pattern comes up
So basically the pattern would be :
Name1.......[213]
No given amount of periods, and this could happen multiple times on a line
Name1....[121] Name2...[1] Name3...[34]
Lets say I want to 'whois %1' everytime I see this, how would I go about doing this?
#trigger {Name1[.]~[%d~]} {}
li'l shmoe of Dragon's Gate MUD |
|
|
|
Saffire Newbie
Joined: 09 Aug 2002 Posts: 3
|
Posted: Tue Aug 13, 2002 6:20 pm |
Err, ok, I want the pattern to be (%w)[.]~[%d~], but it still only gets one instance, rather then however many I have on the same line.
|
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Tue Aug 13, 2002 7:04 pm |
Grab the whole line and convert it to a stringlist using the space as a delimiter. Then, on each one, grab the name by using the period as a delimiter:
#TRIGGER {(*)} {#FORALL %replace("%1", " ", "|") {whois %word(%i, 1, ".")}} "" {notrig}
You need, however, to enable this trigger only when it is necessary and disable it when it is not. You would not want this trigger firing on every word that your MUD sends.
Remember, there are many different way to approach and solve a particular problem, unless specifics about the problem are given, a general solution may be provided which doesn't quite fit what you need.
Kjata |
|
|
|
|
|