[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Simple kill alias

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Simple kill alias

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Pages: 1  2  3  4 

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] 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
[Go to top] top

Posted by Blixel   (39 posts)  [Biography] 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.
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] 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
[Go to top] 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:  [Previous page]  1  2  3  4 

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]