Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
GooGoo
(4 posts) bio
|
| Date |
Wed 08 Feb 2012 09:31 PM (UTC) [ quote
] |
| Message |
I am trying to accomplish this script with LUA. Most forum entries I have read seem to over complicate the task.
Is there an easy way to accomplish this:
Alias GO (send to script)
Attack a "monstername"
Wait for "you killed <monstername>
Attack a "monstername"
wait for "you killed <monstername>
..
..
..
Until you receive "no <monstername> to attack"
send to world "go east"
Thanks | top |
|
| Posted by |
Fiendish
USA (851 posts) bio
Global Moderator |
| Date |
Reply #1 on Thu 09 Feb 2012 03:27 AM (UTC) [ quote
] |
| Message |
|
| Posted by |
Nick Gammon
Australia (18,797 posts) bio
Forum Administrator |
| Date |
Reply #2 on Thu 09 Feb 2012 03:28 AM (UTC) [ quote
] |
| Message |
You need to use the wait module.
http://www.gammon.com.au/forum/?id=4957
Here is an example:
<aliases>
<alias
match="GO *"
enabled="y"
send_to="12"
sequence="100"
>
<send>
require "wait"
function cr ()
monsterName = "%1"
repeat
-- attack the mob
Send ("attack " .. monsterName)
-- wait until it is dead
line, wildcards = wait.regexp ("(You killed %1)|(No %1 to attack)")
until string.find (line, "No %1 to attack")
Send "go east"
end -- of function cr
wait.make (cr) -- start coroutine up
</send>
</alias>
</aliases>
You will need to modify the regular expression to match *exactly* what you see.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
| Posted by |
Nick Gammon
Australia (18,797 posts) bio
Forum Administrator |
| Date |
Reply #3 on Thu 09 Feb 2012 03:29 AM (UTC) [ quote
] |
| Message |
| Ninja! Plus what Fiendish said. :) |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
| Posted by |
Fiendish
USA (851 posts) bio
Global Moderator |
| Date |
Reply #4 on Thu 09 Feb 2012 03:55 AM (UTC) [ quote
] |
| Message |
Quote: You need to use the wait module.
I don't think you do. A trigger on "you killed..." that attacks and a trigger on "no monster..." that moves and attacks will do what was requested. |
http://aardwolfclientpackage.googlecode.com/ | top |
|
| Posted by |
Nick Gammon
Australia (18,797 posts) bio
Forum Administrator |
| Date |
Reply #5 on Thu 09 Feb 2012 04:49 AM (UTC) [ quote
] |
| Message |
Oh, OK. You can manage it with multiple triggers, indeed.
That may well suit you, to break down the problem into smaller parts.
The "wait" module idea shows the flow of decisions in a single place. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
| Posted by |
GooGoo
(4 posts) bio
|
| Date |
Reply #6 on Thu 09 Feb 2012 06:26 AM (UTC) [ quote
] |
| Message |
Hey,
Thanks for responding and helping out a complete newb, much appreciated. I have reviewed the above links. I don't necessarily even need to target the mob, I can just type in the name. Does this script continue to type kill dog or does it type it once then wait for a response?
<alias
match="GO"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>require "wait"
function cr ()
repeat
Send "kill dog"
line, wildcards = wait.regexp ("^(You killed dog)|(No dog here!)$")
until string.find (line, "^No dog here!$")
Send "west"
end -- of function cr
wait.make (cr) -- start coroutine up</send>
I get the following error
Expected statement
Line in error:
until string.find (line, "^No dog here!$")
Thanks. | top |
|
| Posted by |
GooGoo
(4 posts) bio
|
| Date |
Reply #7 on Thu 09 Feb 2012 06:32 AM (UTC) [ quote
] |
| Message |
Sorry, this is it. Same error.
<send>require "wait"
function cr ()
repeat
Send "kill dog"
line, wildcards = wait.regexp ("^No dog here!)$")
until string.find (line, "^No dog here!$")
Send "west"
end -- of function cr
wait.make (cr) -- start coroutine up</send>
I only need to action one string-> No Dog here!. No choice needed. | 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.
1,403 views.
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 )