[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]  Newbie Scripting help

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

Newbie Scripting help

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


Posted by GooGoo   (4 posts)  [Biography] 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
[Go to top] top

Posted by Fiendish   USA  (851 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Thu 09 Feb 2012 03:27 AM (UTC)  quote  ]
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

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

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

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

Posted by Fiendish   USA  (851 posts)  [Biography] 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/
[Go to top] top

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

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

Posted by GooGoo   (4 posts)  [Biography] 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.
[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.


1,403 views.

[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]