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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Counting the number of times of a phrase received
Counting the number of times of a phrase received
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Artel
USA (65 posts) Bio
|
Date
| Thu 21 Oct 2004 02:28 AM (UTC) |
Message
| Sorry for the repost, I think I was on the wrong board..anyways:
I want to count the number of times a particular person says a particular phrase on two different channels.(q/a channel)
For example:
Rathik answers 'yes :)'
Rathik questions 'anyone help me? :) Please? :)'
I want to make a few triggers that will record the number of times :) is said by a particular player on the question and answer channel. After each :) by only that particular player, I also want to send to commands to the world, 'desc -' and 'desc +<number of total :)>'. So far, there have been three :) in the example.
But, I don't see a way to do this.
Any help would be greatly appreciated.
|
Artel. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #1 on Thu 21 Oct 2004 04:43 AM (UTC) Amended on Thu 21 Oct 2004 04:46 AM (UTC) by Flannel
|
Message
| You can do it a few ways, one requires three triggers, the other requires one, but then takes some scripting.
Actually, I cant seem to get the multiple trigger one working.
Nick, I have a regexp to match on :) and it matches multiple times, but the script only executes once (per line)? Is that a bug?
Also, if I use positive lookahead (?=) without a end of line ($) mushclient hangs. Is this new (is it thinking that it might be a multiline thing?), heck, it actually hangs sometimes a few lines before its even turned on (is that time between recieve and display?), sort of wierd stuff going on with that positive lookahead.
But just match on any line with a trigger ("XXX (questions|answers) (.*):)")
and then use %0 (which is the full line) and use VBscript to search for ":)" in that, and then add that to a variable. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #2 on Thu 21 Oct 2004 05:21 AM (UTC) |
Message
| Scripts are queued up and only executed once per line, even if there were multiple matches on a regexp.
I'm not sure about the hang on the lookahead regexp, could be a bug there.
What might work for you is to have a regexp matching ":)" and then in a script do a "split" using ":)" as the splitting delimiter. Then see how many array items you get from the split.
eg.
blah :) blah :) blah
If split at :) would give 3 items, so there must have been two delimiters. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Artel
USA (65 posts) Bio
|
Date
| Reply #3 on Thu 21 Oct 2004 11:19 PM (UTC) |
Message
| I have the one :) per line working fine now. I just don't have enough scripting knowledge to try to count two :) in a line. If it is going to be really complicated, I could just settle for what I have. |
Artel. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #4 on Fri 22 Oct 2004 12:50 AM (UTC) |
Message
| Change the regexp to whatever it should be. I tried to make it what you said it was though.
This works though, just make sure the trigger catches the full line.
I also colored it so you can test to make sure its matching, and it notes instead of sending. Tweak that, obviously.
<triggers>
<trigger
custom_colour="1"
enabled="y"
ignore_case="y"
keep_evaluating="y"
match="^Rathik (questions|answers) \'(.*?)\:\)(.*?)\'$"
regexp="y"
send_to="12"
sequence="100"
>
<send>Dim SmileArray, i, j
SmileArray = Split("%0", ":)", -1, 1)
j = -1
For Each i in SmileArray
j = j + 1
Next
setvariable "smilecount", CInt(getvariable("smilecount")) + j
note getvariable("smilecount")</send>
</trigger>
</triggers>
<variables>
<variable name="smilecount">0</variable>
</variables>
|
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Artel
USA (65 posts) Bio
|
Date
| Reply #5 on Tue 26 Oct 2004 04:28 AM (UTC) |
Message
| Now how would I match everything except something?
I tried the help file, and I couldn't get it to work. (nothing happens)
^(?!Rathik) answers \'(.*?)\'$<-- that is the right way to match everything except me, right?
|
Artel. | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #6 on Tue 26 Oct 2004 06:40 AM (UTC) |
Message
| This is a completely different topic, right? Can you start a new thread? No-one will look here for "how to match everyone but me". |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
19,724 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top