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
➜ Simple kill alias
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2
3
4
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #45 on Sat 24 Sep 2011 04:03 AM (UTC) |
Message
| What is this intended to do?
x = ("^The .*? (is slain!)|(flees in panic!)|(^There is no .*? here\.$)|(^You can\'t attack yourself!$)|
(^A being clothed in white appears before you\.$)|(^Do what\.?$)|(^The dead have no need to fight\.$)")
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Blixel
(80 posts) Bio
|
Date
| Reply #46 on Sat 24 Sep 2011 05:12 AM (UTC) Amended on Sat 24 Sep 2011 05:13 AM (UTC) by Blixel
|
Message
|
Nick Gammon said:
What is this intended to do?
x = ("^The .*? (is slain!)|(flees in panic!)|(^There is no .*? here\.$)|(^You can\'t attack yourself!$)|
(^A being clothed in white appears before you\.$)|(^Do what\.?$)|(^The dead have no need to fight\.$)")
The original code for that was this:
x = wait.regexp ("^The .*? (is slain!)|(flees in panic!)|(^There is no .*? here\.$)|(^You can\'t attack yourself!$)|
(^A being clothed in white appears before you\.$)|(^Do what\.?$)", 1)
But I am to understand you can't use wait in a function, so it had to be replaced. I tried replacing it with this:
x = match.regexp ("^The .*? (is slain!)|(flees in panic!)|(^There is no .*? here\.$)|(^You can\'t attack yourself!$)|
(^A being clothed in white appears before you\.$)|(^Do what\.?$)")
I thought I had seen match.regexp used somewhere before, but apparently there's no such function.
So, I am still trying to figure out how to replace x = wait.regexp (....) with some similar code that will work in a function.
| Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #47 on Sat 24 Sep 2011 06:34 AM (UTC) |
Message
|
Blixel said: But I am to understand you can't use wait in a function, so it had to be replaced.
Certainly it can. He's not saying that it can't be used in a function. This is the critical line that is being disagreed with:
Blixel said: But I don't need the alias in order to test if this function is working (fundamentally). If it doesn't work by calling it directly, then it's not going to work by having an alias "on top" of it.
You need to understand that this function isn't as self-contained as it might appear. To use this function, it must be called from within a wait.make() block, because it assumes that it can use wait.match(). So it's valid to call from your alias because your alias uses the wait module. However, you can't do a naive call of the function. If you want to call it standalone, you'd need to call it like this:
wait.make(function()
mobkillengine("dark link")
end)
If you called it straight (i.e. directly from the main line of execution instead of from a wait coroutine), it wouldn't work, because there is no active coroutine to pause and resume. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | 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.
124,926 views.
This is page 4, subject is 4 pages long:
1
2
3
4
It is now over 60 days since the last post. This thread is closed.
Refresh page
top