Hello,
I've been messing around with reg expressions and find them excellent.
I'm confused on one part however.
This is just an example of what I'm trying to match...
You notice a dog walk north.
Easy enough to send the mob to a variable.
^You notice (a|an|the) (.*?) walk north\.$
What baffles me is the following...
You notice papa smirf walk north.
I could make 2 different triggers.
^You notice (.*?) walk north\.$
I'm curious if it's possible to use one trigger so I don't have to deal with 2 triggers as they conflict with each other.
Any help would be appreciated.
Thanks
Zack
You could make that part (a|an|the) optional:
^You notice ((a|an|the) )?(.*?) walk north\.$
My next question is how do I count these out?
Example
The dancing monkey arrives from the east.
^((A|An|The) )?(.*?) arrives from the (.*?)\.$
I want to send the npc's name "dancing monkey" to a variable. Would it be %2?
also lets say I just wanted to send monkey and not dancing is that possible provided a mob has a 2 word title? Dancing monkey, leaning lion,
thanks
Z
%3 I would guess because you have two sets of captures before it.
And yes you can split variables up at words. Might want to do that with Lua after the capture.
Thank you so much for answering my question.
Could you give me an example or a link that would show me how to break the variables up in Lua?
Example: A large dog leaves east.
%((A\An|The) )?(.*?) leaves east>
Large dog would be sent to the variable.
I just want to have dog be in the variable.
I'm trying to become as good as I can with Mush so I can make my mudding enhanced.
Thank you.
Zack
Is this Lua or the trigger matching? Can you post what you are actually doing?
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see
Copying XML.
Okay I think this should have copied it.
code
<triggers>
<trigger
enabled="y"
keep_evaluating="y"
match="^(.*?)((A|An|The) )? (.*?) panics, and attempts to flee(.*?)$"
regexp="y"
repeat="y"
send_to="9"
sequence="100"
variable="flee"
>
<send>%3</send>
</trigger>
<trigger
enabled="y"
expand_variables="y"
keep_evaluating="y"
match="^(.*?)((A|An|The) )? @target leaves (.*?)\\."
regexp="y"
repeat="y"
sequence="100"
>
<send>%4
kill %3</send>
</trigger>
</triggers>
<variables>
<variable name="flee"></variable>
</variables>
/code