Simple trigger - little help needed

Posted by English Lad on Sat 18 Oct 2008 07:38 PM — 6 posts, 26,909 views.

#0
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?
Netherlands #1
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.
USA #2
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"
Australia Forum Administrator #3
Can't you do something like:


give "%2" %1


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



#4
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?
Amended on Mon 20 Oct 2008 02:35 PM by English Lad
USA #5
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.