Search FAQ

Gammon Forum

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.
 Entire forum ➜ MUSHclient ➜ VBscript ➜ Simple trigger - little help needed

Simple trigger - little help needed

Posting of new messages is disabled at present.

Refresh page


Posted by English Lad   (4 posts)  Bio
Date Sat 18 Oct 2008 07:38 PM (UTC)
Message
Hi all.

What i want to do should be pretty easy, so i'm sure i'm just unable to locate the right helpfile, have spent a little while looking.

Basic principal is a trigger to bless items for other people, and hand them back to people.

Triggering off: * gives you *
In the trigger then is;
c bless %2
give %2 %1

This works fine when the item i'm given only has one word in the short description eg apple.

It does this Bob gives you apple.
c bless apple
give apple bob.

The problem is when the short description has two or more words eg red apple.

Bob gives you red apple
c bless red apple - Works fine
give red apple bob - Doesn't work, as the mud tried to give red to apple.

have tried putting the information in ' and " but the problem is then the mud doesn't recognise the item at all.

What should solve the problem is make the * in the original trigger only pick up the 1st word, but despite trawling helpfiles i couldn't get it to.

What am I missing?
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #1 on Sat 18 Oct 2008 07:47 PM (UTC)
Message
Try using the following regular expression (select the Regular Expression box):

^(\w+) gives you ((\w+)(?: .*)?)$

Short explanation:
^ means beginning of line.
(\w+) means one word of one or more characters which is captured with () into %1.
(...) captures the stuff inbetween into %2
(\w+) same as above, for %3.
(?: .*)? optionally takes the remainder of a line.
$ means end of line.

You can use that in combination with:

c bless %2
give %3 %1

This way, the bless-cast will still use the full item name.
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #2 on Sat 18 Oct 2008 08:36 PM (UTC)
Message
There's a problem with the above. It will end up sending "give red bob". The problem with making a trigger is knowing where the noun is. How can we systematically deduce if bob's giving you a "red apple" or "sword of slaying"?

I'd suggest seeing if your mud have a more verbose way to give things. i.e. "give red apple to bob"
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 19 Oct 2008 03:18 AM (UTC)
Message
Can't you do something like:


give "%2" %1


That way you quote the thing that is being given. (the red apple).




- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by English Lad   (4 posts)  Bio
Date Reply #4 on Mon 20 Oct 2008 01:10 PM (UTC)

Amended on Mon 20 Oct 2008 02:35 PM (UTC) by English Lad

Message
Ok well it was simpler than i thought when i worked it out.

Unfortunately the MUD doesn't recognise the item with " around it, but what i did was this

* gives you * * *
c bless %3
give %3 %1

The 1st * is obviously the person's name, the second 1 picks up a an the some etc..... the third picks up the 1st word in the items short description, but because there is a fourth (which i don't use) it doesn't pick up the rest of the short desc.

This isn't perfect, as some items has a short desc format that doesn't fit, and some items don't have the 1st word in the short desc as a keyword, but it works for 95% of the stuff i need to use it on. What i'm doing is producing a list of items, as and when they come up, that don't have the 1st word as a keyword, and making a trigger just for them, which should in time pick them all up.

Thanks all

EDIT

Ok slightly new problem - I knew from the start that their would be items that wouldn't work, as the 1st word in their short desc wouldn't be a keyword. My plan was that when I came across these I would make a trigger for each.

EG

Bob gives you a red apple - Doesn't work if the red apple doesn't have red as a keyword.

There are only a few of these so what i would do is, when i find one make a trigger for it individually. Rather than using:

* gives you * * *

I would use

* gives you a red apple.
and then gave the output as give %1 apple.

These are all obviously made by hand, to get around the problem of the short desc not matching the keyword. The problem i'm having is that the original trigger runs, not the new one i've made specifically for that item, as it still matches the criteria with the wild cards. Is there anyway to make it so that the individual triggers for unsual items take prescedence over the general all purpose one?
Top

Posted by Cage_fire_2000   USA  (119 posts)  Bio
Date Reply #5 on Mon 20 Oct 2008 07:36 PM (UTC)
Message
Yes, there is. It's very easy. In the trigger dialog box(as well as the aliases) there is a box labeled 'sequence' this is the priority of the trigger, the lower the number the earlier it'll be checked, so just change the sequence number to something lower than that of your general trigger. Like 99 for example. You can put all the custom triggers at 99 and as long as the general one is at 100, the custom ones will be checked first, and as long as you don't have 'keep evaluating' checked it will stop with the first one that matches. Alternatively you could just raise the sequence number of the general trigger.
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.


20,039 views.

Posting of new messages is disabled at present.

Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.