What string is 'captured', but having problems.

Posted by Avocado on Wed 30 Oct 2013 11:50 PM — 2 posts, 12,549 views.

#0
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>
Australia Forum Administrator #1

 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.