Register forum user name Search FAQ

Gammon Forum

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 ➜ Newbie Scripting help

Newbie Scripting help

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by GooGoo   (4 posts)  Bio
Date Wed 08 Feb 2012 09:31 PM (UTC)
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  (2,555 posts)  Bio   Global Moderator
Date Reply #1 on Thu 09 Feb 2012 03:27 AM (UTC)
Message
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

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Thu 09 Feb 2012 03:28 AM (UTC)
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  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 09 Feb 2012 03:29 AM (UTC)
Message
Ninja! Plus what Fiendish said. :)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,555 posts)  Bio   Global Moderator
Date Reply #4 on Thu 09 Feb 2012 03:55 AM (UTC)
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.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 09 Feb 2012 04:49 AM (UTC)
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)
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)
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.


26,513 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.