Help with triggers

Post Reply
Rodrick
Posts: 3
Joined: Wed Jul 27, 2016 8:16 pm

Help with triggers

Post by Rodrick »

Hello all... i've searched the forums for the answer and didnt find anything so forgive me if its out there and i just didnt find it.

What i'm trying to do is have an character follow mine around and attack whatever i attack... basically it would look for something like "Rodrick moves to attack <monster>" ... i have no idea how to pull the monster name in and have it spit out 'attack zombie' or 'attack wolf'

Thanks in advance for any help or pointers.

-Rod

Rodrick
Posts: 3
Joined: Wed Jul 27, 2016 8:16 pm

Re: Help with triggers

Post by Rodrick »

This is what i am trying... from what i understand it should be working, but it never fires


^Bob moves to attack (\w+)$ -- perl regex


Send("attack " .. matches[2])



Screen Shot 2016-07-29 at 1.25.14 PM.png
Screen Shot 2016-07-29 at 1.25.14 PM.png (60.92 KiB) Viewed 13007 times

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Help with triggers

Post by SlySven »

Is there any punctuation at the end of the sentence? "(\w+)" catches word characters but I suspect that does not include a terminating period/full-stop '.' and the '$' is a meta-character meaning "end-of-line" so the trigger will not fire if there is that character ('.') on the end!

Rodrick
Posts: 3
Joined: Wed Jul 27, 2016 8:16 pm

Re: Help with triggers

Post by Rodrick »

Yep... the line actually looks like:

Bob moves to attack nasty giant rat.

so looks like what i have will not work at all.


Also tried using:

Bob moves to attack (\w[\w ]*\w).$

thinking that would catch the spaces, and multiple words.. still no good.. I am regex handicapped. :|

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Help with triggers

Post by SlySven »

Humm, what about:

Code: Select all

^Bob moves to attack (.*).$
For "Bob moves to attack the hairy-legged, blue spider."
matches[2] will contain "the hairy-legged, blue spider"...

Try https://regex101.com/ perhaps that can help you deal with your condition? :)

Post Reply