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
What forum threads did you read?
It's a simple matter of combining an alias based on this information:
http://www.gammon.com.au/forum/?id=9616
with a trigger based on this information:
http://mushclient.com/forum/?id=7794#22
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.
Ninja! Plus what Fiendish said. :)
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.
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.
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.
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.