Right, I'm new to this whole triggers business, I thought I could figure it out on my own, but I can't manage to work out how to do a target defence. ( I.E. find someone's name and use it in the defence response. ) I am very new to this kind of thing, by the by.
Here's the line which should start off the defence:
^(\w+) strikes out at you powerfully\.$
So, I'd presume the response is BLOCK (\w+), but that doesn't seem to work, and it doesn't look like Mudlet likes it. I'd also like a single trigger list to do the same response, but I'm unsure if I can do an entire list with each other being a single variable that causes me to do it. Any ideas, guys?
Thank you in advance for any responses.
Defending Triggers in Midkemia Online
Re: Defending Triggers in Midkemia Online
First of all make sure the trigger is matching - set it to the "perl regex" pattern.
Secondly, the (\w+) becomes translates to matches[2] in the script. So your script should be:
Secondly, the (\w+) becomes translates to matches[2] in the script. So your script should be:
Code: Select all
send("block " .. matches[2])
-
- Posts: 1
- Joined: Thu Mar 11, 2010 9:42 pm
Re: Defending Triggers in Midkemia Online
Thanks alot for the previous info, it helped alot but now I have a new question. How do I use wild cards to deal with an trigger like this
<attacker> decisively punctures through your defenses with an ornate steel poniard.
At this time since most of the population on Midkemia has the standard weapons I'm surviving but when player made weapons become more popular I'll need to replace the weapon name with a wild card.
My issue is how do I use a wild card for an indetermined number of words. (Some weapons have 1 word names, others have 3) Just looking for direction on how to deal with that.
<attacker> decisively punctures through your defenses with an ornate steel poniard.
At this time since most of the population on Midkemia has the standard weapons I'm surviving but when player made weapons become more popular I'll need to replace the weapon name with a wild card.
My issue is how do I use a wild card for an indetermined number of words. (Some weapons have 1 word names, others have 3) Just looking for direction on how to deal with that.
Re: Defending Triggers in Midkemia Online
Easiest thing to do is probably just cut the trigger off before the weapon name starts, so use this:
Code: Select all
(\w+) decisively punctures through your defenses with a
Re: Defending Triggers in Midkemia Online
For the future, I believe this would match multiple words that are separated by spaces, any amount of:
((\w+) )+
((\w+) )+
Re: Defending Triggers in Midkemia Online
I'd use
((?:\w+) )+
to capture the group rather than the individual word.
Although,
([a-zA-Z ]+)
would also work, so it's a matter of taste.
Edit: Vadi's way would certainly capture the group, by the way. It would just also capture each word within the group, which is inefficient.
It also has a side effect of requiring a space after the last word in the group (which means if it were the last word in the sentence, that word wouldn't capture). My first suggestion also suffers this. You -could- add a question mark after that space to make it optional.
Yeah, i know, too much information, but I like to over-inform.
((?:\w+) )+
to capture the group rather than the individual word.
Although,
([a-zA-Z ]+)
would also work, so it's a matter of taste.
Edit: Vadi's way would certainly capture the group, by the way. It would just also capture each word within the group, which is inefficient.
It also has a side effect of requiring a space after the last word in the group (which means if it were the last word in the sentence, that word wouldn't capture). My first suggestion also suffers this. You -could- add a question mark after that space to make it optional.
Yeah, i know, too much information, but I like to over-inform.
Last edited by tsuujin on Fri Mar 12, 2010 1:26 am, edited 1 time in total.
Re: Defending Triggers in Midkemia Online
Also, just for a bit of variety, I'd use this for your first trigger:
^[A-Z][a-z]+ strikes out at you powerfully\.$
I'm a bit of a perfectionist, and this will make sure that the line uses a capitalized player name. I do this uniformly through my custom system to match player names.
^[A-Z][a-z]+ strikes out at you powerfully\.$
I'm a bit of a perfectionist, and this will make sure that the line uses a capitalized player name. I do this uniformly through my custom system to match player names.