Reply to this subject
Start a new subject
 
Refresh page
Pages: 1
2
3
4
| Posted by |
Nick Gammon
Australia (18,770 posts) bio
Forum Administrator |
| Date |
Reply #45 on Sat 24 Sep 2011 04:03 AM (UTC) [ quote
] |
| 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
(39 posts) bio
|
| Date |
Reply #46 on Sat 24 Sep 2011 05:12 AM (UTC) [ quote
] 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,229 posts) bio
|
| Date |
Reply #47 on Sat 24 Sep 2011 06:34 AM (UTC) [ quote
] |
| 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.
4,475 views.
This is page 4, subject is 4 pages long:
1
2
3
4
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )