![](templates/Classic/images/spacer.gif) |
vimvam Newbie
Joined: 03 May 2002 Posts: 2
|
Posted: Mon Apr 01, 2002 7:24 pm
Can only get trigger to fire once per line... |
Sorry for the double posts. I got to thinking that I may not be stating my problem clearly. I need to count the instances of a certain word in one line of output from my MUD. For example, if I see:
You also see an orc, an orc, and an orc.
And I set the following trigger:
#TR {orc} {#AD orcs 1}
...it will only fire once giving me an obviously inaccurate count of my enemies. I've tried any number of ways around this and cannot figure anything out. I can't really set the trigger to be more specific, because any number of things can be thrown in with the orcs.
Example:
You also see an orc, a broken bottle, an orc, some junk, another orc.
I am at my wits end.
One thing I don't understand, is that if I just set the trigger to color the word it will color all instances, but still only counts the word once.
Thx in advance
Jim |
|
|
![](templates/Classic/images/spacer.gif) |
TonDiening GURU
![](images/avatars/35418510744b1b6777b5a3.gif)
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Mon Apr 01, 2002 7:30 pm |
#TRIGGER {You also see (%*).} {#VAR numorcs %numwords( "%1", " orc")}
How about that? Assumes orcs always look
like " orc". This will catch orcfoo and
orcbar patterns though.
Ton Diening |
|
|
![](templates/Classic/images/spacer.gif) |
vimvam Newbie
Joined: 03 May 2002 Posts: 2
|
Posted: Mon Apr 01, 2002 8:35 pm |
I am really about to kill myself with frustration. Good suggestion, but it's still not working exactly right.
Okay, this trigger:
#TR {You also see (%*).} {#VA enemiesinroom {%1}}
Takes this pattern:
You also see an orc, an orc, and some junk.
And sets @enemiesinroom to {an orc, an orc, and some junk}
So why, when I do: #SH %numwords(@enemiesinroom,orc)
...does it give me the number 3 every time?
Is there another command for returning the number of instances of a word in a string that I am missing? |
|
|
![](templates/Classic/images/spacer.gif) |
kognesty Newbie
Joined: 08 Jan 2001 Posts: 8 Location: USA
|
Posted: Mon Apr 01, 2002 9:58 pm |
Well, I posted a solution to your troubles in the other post you made, but to explain why the thing you did failed is easy. %numwords counts the number of words in the string given according to a deliminator so %numwords( %1, orc) will count the number of words it catchs using orc as a means to seperate words, not as a means of how many times orc appears in the string. So a string containing orc twice will use orc as a deliminator twice and you'll get three words and two "spaces". In a string with only one orc, you'll get two words and one "space". Which could work if you always assume the number you get is one more then the actual number of orcs present.
|
|
|
![](templates/Classic/images/spacer.gif) |
TonDiening GURU
![](images/avatars/35418510744b1b6777b5a3.gif)
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Tue Apr 02, 2002 1:37 am |
Indeed. My logic mistake.
I forgot that stuff ORC stuff ORC stuff
would be counted as 3 things.
Ton Diening |
|
|
![](templates/Classic/images/spacer.gif) |
|
|
|
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
|
|