Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Using ( | | )

Using ( | | )

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Zack   (23 posts)  Bio
Date Thu 28 Mar 2013 07:21 AM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 29 Mar 2013 01:06 AM (UTC)
Message
You could make that part (a|an|the) optional:


 ^You notice ((a|an|the) )?(.*?) walk north\.$ 

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zack   (23 posts)  Bio
Date Reply #2 on Tue 02 Apr 2013 07:38 AM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 03 Apr 2013 10:50 AM (UTC)
Message
%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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zack   (23 posts)  Bio
Date Reply #4 on Sat 20 Apr 2013 04:19 PM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #5 on Sun 21 Apr 2013 10:07 AM (UTC)
Message
Is this Lua or the trigger matching? Can you post what you are actually doing?

Template:copying For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zack   (23 posts)  Bio
Date Reply #6 on Sun 21 Apr 2013 10:22 PM (UTC)
Message
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
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


19,249 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.