catching certain variables possible?

Posted by Kurapiira on Fri 19 Nov 2010 02:59 AM — 4 posts, 17,891 views.

#0
Hi,
trying to make a trigger to catch certain parts of a line.

The 1st hulking troll punches at you
the 2nd mountainous drooling ogre bites at you
The 4th firefly bites you
Harru claws you

Is it possible to save certain parts of the
line as a variable?

I'm trying to catch which one (1st,2nd,3rd)
I'm trying to catch the name preceding the attack type
Also would be nice to have different attack types
(bites|punches|claws)

so No matter what attacks, i can respond in a certain way
kill 1 troll
riposte 2 ogre
counter 4 firefly
claw harru...etc


this isn't working..am I even close?
thanks for any help or info

Kura

Trigger:

^The (.%d?)(.%w?) (.*?) (.%w?) attacks you with (.*?)\, but you evade the strike\!$

Amended on Fri 19 Nov 2010 03:03 AM by Kurapiira
Australia Forum Administrator #1
In triggers you use backslashes, not % symbols for special classes. This sort-of works, it should get you started:


<triggers>
  <trigger
   enabled="y"
   match="^The (?'which'\d+)(st|nd|rd|th) (?'mob'[a-zA-Z ]+) (?'attack'bites|punches|claws) (at )?you"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

print ("which = %&lt;which&gt;")
print ("mob = %&lt;mob&gt;")
print ("attack = %&lt;attack&gt;")

local reply = "kick"
local which = %&lt;which&gt;
local last_mob_word = string.match ("%&lt;mob&gt;", "%%a+$")

Send (string.format ("%s %i %s", reply, which, last_mob_word))

</send>
  </trigger>
</triggers>



Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
#2

Thanks sooo much, am trying it now..
will post if i can get it going :)

K.
#3
It's working for Mobs that bite/claw/punch AT me,
but not for this...

The 1st animated training dummy attacks you with its simple wooden training sword, but you parry the blow with your claws!

I tried doing this..

...?you(.*?), but you parry the


just not sure how to do it..do i need
2 triggers?..one for natural attacks and one for weapons?

p.s. what is the question mark before YOU for?
Thanks for any help :)



<triggers>
<trigger
enabled="y"
match="^The (?'which'\d+)(st|nd|rd|th) (?'mob'[a-zA-Z ]+) (?'attack'bites|punches|claws|attacks) (at )?you, but you parry the "
regexp="y"
send_to="12"
sequence="100"
>
<send>print ("which = %&lt;which&gt;")
print ("mob = %&lt;mob&gt;")
print ("attack = %&lt;attack&gt;")

local reply = "batt rip"
local which = %&lt;which&gt;
local last_mob_word = string.match ("%&lt;mob&gt;", "%%a+$")

Send (string.format ("%s %i %s", reply, which, last_mob_word))

</send>
</trigger>
</triggers>