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
➜ I hate spaces, asterisks and triggers.
|
I hate spaces, asterisks and triggers.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Shaun Biggs
USA (644 posts) Bio
|
| Date
| Mon 21 Jul 2003 02:04 PM (UTC) |
| Message
| I'm trying to make a script to capture quest rewards on Aardwolf, and I some of the output unfortunately has asterisks in it. I think I escaped them correctly in the trigger, but it fails to go off properly. What am I missing?
the triggers:
^\*\* You gain a bonus trivia point! \*\*$
^\*\* You gain a bonus*practices? \*\*$
Should capture any of the following:
** You gain a bonus trivia point! **
** You gain a bonus practice **
** You gain a bonus 3 practices **
Right? Neither trigger works, so obviously no...
|
It is much easier to fight for one's ideals than to live up to them. | | Top |
|
| Posted by
| Sleeve
(31 posts) Bio
|
| Date
| Reply #1 on Mon 21 Jul 2003 04:55 PM (UTC) Amended on Mon 21 Jul 2003 05:03 PM (UTC) by Sleeve
|
| Message
| Hmm, I really don't see the problem with your trivia point trigger, is the regular expression checkbox checked for that trigger?
For the practice one, you could always split them up into 2 different triggers, or you could try something like this:
^\*\* You gain a bonus (|\d)(| )practice(|s) \*\*$
The reason I split it up like that for the number part is so that if you want to work with that first wildcard in a script you would get: "3" instead of "3 ". Again, make sure regular expression is checked, or this will not work. I'm not great with regex, so perhaps someone can find a better way than this.
If you don't need to work with any wildcards in a script, this will do:
^\*\* You gain a bonus(|\d ) practice(|s) \*\*$ | | Top |
|
| Posted by
| Shaun Biggs
USA (644 posts) Bio
|
| Date
| Reply #2 on Mon 21 Jul 2003 05:25 PM (UTC) Amended on Mon 21 Jul 2003 05:33 PM (UTC) by Shaun Biggs
|
| Message
| First, both triggers are regular expressions as far as I can tell. I've checked that over repeatedly. Unless the XML notation for it is not RegExp="y" they should be fine.
Secondly, there's no point in making the practice part be two triggers. I'm just having them put into a variable to be diplayed later. For one prac, it would add ", prac" and for the multiple one, it would add ", 3 pracs" in the script.
and the prac trigger is what I had set it to when I was making sure I didn't just screw things up making it more complicated than it needed to be. Here is what it originally was:
^\*\* You gain a bonus*practice(s?) \*\*$
function addpracs() {
wildcards = VBArray(wildcardsVB).toArray();
world.setVariable( "gainsOther", ( world.getVariable( "gainsOther" ) + "," + wildcards[0] + "prac" +wildcards[1] ) )
} // addpracs
The script is JScript, btw. |
It is much easier to fight for one's ideals than to live up to them. | | Top |
|
| Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
| Date
| Reply #3 on Mon 21 Jul 2003 06:59 PM (UTC) Amended on Mon 21 Jul 2003 07:04 PM (UTC) by Shadowfyr
|
| Message
| Well. The problem is that * by itself means 'look for one or more of the -previous- character' when using a regular expression. So taking a look at your trigger we get:
^ - Start checking at the beginning of the line.
\*\* You gain a bonu - Find two asterisk, the part of a sentence.
s* - Find one or more 's' (Ooops!)
practices? \*\*$ - And so on.
Obviously s* isn't what you wanted. ;) What you need is:
^\*\* You gain a bonus\s?(\d+)? practice(s?) \*\*$
\s? means it will accept an extra space if one is found. This is important, I spent 3-4 days trying to figure out why a trigger I had made refused to work before realizing that it was testing for the wrong number of spaces in like 7 out of the 8 types of lines it 'should' have accepted. lol
(\d+)? means:
() - Make this part a wild card. If you leave this off, it will match, but you will never see the value it found. ;)
\d+ - Match if there are one or more numbers here.
? - Match the line, even if what the contents of () looks for is missing. Sleeve's suggestion may work too, but it is a bit less straight forward, since it uses | to specify 'one or the other'. Imho it is easier to simply tell the trigger to ignore something it doesn't need. | is more useful in cases where you have a trigger that needs to match on one of three or more names, objects, etc. that you already know the to look for. In this case, it doesn't do much.
Notice that at the end it also has (s?). () tells Mushclient to return a wildcard, but it also functions as a way to tell it that what is inside of them is 'by itself'. I am not sure, but the way you had it may have been telling Mushclient to 'match even if the entire word practices is missing', not merely excluding the 's' on the end. ;)
Aren't the rules for Regular Expressions just so much fun? ;) lol
BTW: To avoid confusing yourself in the future, a '*' in a normal trigger becomes '.*' in regular expressions. ;) This is because in normal triggers '*' means 'one or more of anything', while in regular expressions you use '.' - anything + '*' - one or more of the previous match (which you just told it can be anything). | | Top |
|
| Posted by
| Shaun Biggs
USA (644 posts) Bio
|
| Date
| Reply #4 on Mon 21 Jul 2003 07:35 PM (UTC) |
| Message
| Wow... that's a lot of info. Thanks.
I missed the part about needing a period before the asterisk for a wildcard in regular expressions. As for the question mark, the "Fun with triggers" page says
Quote: Matches zero or one of the previous character or set (eg. "dogs?" matches "dog" or "dogs")
I don't need to get a number from between "bonus" and "practice", just a string, so "^\*\* You gain a bonus(.*)practice(s?) \*\*$"
should work.
This all still doesn't eplain why the trivia point line wasn't caught, when it doesn't have any wildcards at all, just asterisks which are escaped.
I'm also tired of waiting half an hour between tests, but I can't con the immortals into resetting my quest timer :) |
It is much easier to fight for one's ideals than to live up to them. | | Top |
|
| Posted by
| Shaun Biggs
USA (644 posts) Bio
|
| Date
| Reply #5 on Mon 21 Jul 2003 08:07 PM (UTC) |
| Message
| heh... I fixed the practices trigger, and the trivia one miraculously started working to for no apparent reason.
Thanks for all your help guys. |
It is much easier to fight for one's ideals than to live up to them. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #6 on Mon 21 Jul 2003 09:00 PM (UTC) |
| Message
| I think Shadowfyr thought you were looking for spaces. Your problem was the missing dot, as you realised. You don't need the brackets if you don't want to keep the results in a wildcard, this will do ...
"^\*\* You gain a bonus.*practices? \*\*$" |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Flannel
USA (1,230 posts) Bio
|
| Date
| Reply #7 on Tue 22 Jul 2003 06:40 AM (UTC) |
| Message
| | And as for waiting however long, ctrl-shift-f12 brings up a handy 'simulate world text' thingie you can use to test triggers. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | | Top |
|
| Posted by
| Shaun Biggs
USA (644 posts) Bio
|
| Date
| Reply #8 on Fri 15 Aug 2003 07:23 PM (UTC) Amended on Fri 15 Aug 2003 08:58 PM (UTC) by Nick Gammon
|
| Message
| Well, I fixed the trivia point trigger, and it worked fine. But I can't get the train or practice triggers to work at all. I realize this is a rather late post, but I spent quite a while on vacation without a computer :)
Here is what I have for the trivia and the trains.
<trigger
enabled="y"
match="^\*\* You gain a bonus trivia point! \*\*$"
name="tpcatcher"
regexp="y"
script="addTP"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="^\*\* You gain a bonus (\d)?\s?training session(s?) \*\*$"
name="traincatcher"
regexp="y"
script="addtrains"
sequence="100"
>
</trigger>
and when I try to match it on:
You inform Questor that you have completed your quest.
Questor tells you 'Congratulations someone on completing your quest!'
Questor tells you 'As a reward, I am giving you 0 quest points and 0 gold.'
** You gain a bonus trivia point! **
** You gain a bonus training session **
You get lucky and gain an extra 0 quest points.
You gain an extra 0 quest points 'MCCP Bonus'.
it will match on the trivia line, but not the train line. (values were set to 0 just so it wouldn't mess up my totals. |
It is much easier to fight for one's ideals than to live up to them. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #9 on Fri 15 Aug 2003 09:04 PM (UTC) |
| Message
| Your trigger is OK except for one thing. If you drag the mouse over the posting above to select it, you will notice a trailing space, which I presume is actually in the MUD output, if you copied and pasted.
ie.
** You gain a bonus training session **(space)
This space is important! You need to add that into the trigger, or alternatively drop the final $ so it doesn't look for the end-of-line.
When a trigger doesn't match, and you think it should, it is always useful to see if there is "hidden" stuff there that the trigger match routine will look for but you can't see. One useful way is to select the line, go to the Display menu -> Text Attributes -> Line Info, and see what appears. In this case I saw:
1: Offset = 0, Length = 40, Text = "** You gain a bonus training session ** "
The final space shows up quite clearly there. :)
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Shaun Biggs
USA (644 posts) Bio
|
| Date
| Reply #10 on Sat 16 Aug 2003 04:51 AM (UTC) |
| Message
| Can I change the topic of this thread to I hate spaces and triggers? Thank you very much, I added the space, and it solved all the problems I was having. You have removed my urge to take a sledgehammer to my keyboard, and I'm sure my computer is grateful too.
|
It is much easier to fight for one's ideals than to live up to them. | | 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,326 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top