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 ➜ Lua ➜ What string is 'captured', but having problems.

What string is 'captured', but having problems.

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


Posted by Avocado   (13 posts)  Bio
Date Wed 30 Oct 2013 11:50 PM (UTC)
Message
Hello, I'm trying to run a below alias. It's named "aven". It is just a short piece. I'm just trying to see what gets 'captured' as x if I type up something like that below.

I want to see how to grab some particular strings from the server, so that in the future, I can compare it and then take different actions. For now, I'm having problem with capturing a string from a choice of lists. (i.e. for below, I'm trying to see if 'Door is closed!' comes up, or my Hit point and mana line "[*/*hp*" comes up, which always comes up last. So that I can move on to next step without doing the 'wait' thing)

This is the error I'm receiving when I tried to run the alias:

Immediate execution
[string "Alias: "]:5: '=' expected near 'x'


Below is the code:

<code>
<aliases>
<alias
match="aven"
enabled="y"
send_to="12"
sequence="100"
>
<send>require "wait"
wait.make(function()
send "east"
local x = wait.match (("The door is closed.") or ("[*/*hp*"), 1)
print x
end) -- end of coroutine</send>
</alias>
</aliases>
</code>
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 31 Oct 2013 07:08 AM (UTC)

Amended on Thu 31 Oct 2013 07:11 AM (UTC) by Nick Gammon

Message

 local x = wait.match (("The door is closed.") or ("[*/*hp*"), 1)


You can't use "or" like that. You need to make the regexp match in a different way.


 local x = wait.regexp ("^(The door is closed\.)|(\[.*/.*hp.*)$", 1)


Template:regexp Regular expressions
  • Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
  • Also see how Lua string matching patterns work, as documented on the Lua string.find page.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


11,959 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.