Defending Triggers in Midkemia Online

Post Reply
Skargak
Posts: 1
Joined: Tue Jan 19, 2010 2:25 pm

Defending Triggers in Midkemia Online

Post by Skargak »

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.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Defending Triggers in Midkemia Online

Post by Vadi »

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:

Code: Select all

send("block " .. matches[2])

BobtheHick
Posts: 1
Joined: Thu Mar 11, 2010 9:42 pm

Re: Defending Triggers in Midkemia Online

Post by BobtheHick »

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.

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: Defending Triggers in Midkemia Online

Post by naftali »

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

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Defending Triggers in Midkemia Online

Post by Vadi »

For the future, I believe this would match multiple words that are separated by spaces, any amount of:

((\w+) )+

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Defending Triggers in Midkemia Online

Post by tsuujin »

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.
Last edited by tsuujin on Fri Mar 12, 2010 1:26 am, edited 1 time in total.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Defending Triggers in Midkemia Online

Post by tsuujin »

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.

Post Reply