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.
 Entire forum ➜ MUSHclient ➜ Lua ➜ Lua Bot

Lua Bot

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


Posted by Eammon Wright   (17 posts)  Bio
Date Tue 29 Sep 2020 06:07 PM (UTC)
Message
Ok, so those that have helped me learn so far know, i'm learning lua making a bot that will walk a square path on this beach, stop when he sees a creature, check stats, kill creature, then resume his path. I want this to run a loop so when he hits the final square he goes back to square one and starts over if that makes sense. So the next part is an Array or a Table I think from what ive read.


ArrayBeach = {w,w,w,w,w,n,e,e,e,e,e,n,w,w,w,w,w,n,e,e,e,e,e,n,w,w,w,w,w,n,e,e,e,e,e,s,s,s,s,s,s,s}

DoAfter (5,ArrayBeach[1])


Now I know very little about this still so i'm taking it one step at a time. I have the array, and when i run the keyword it just does nothing. So if someone is again willing to help, where is my first step in fixing what is wrong with this?
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 30 Sep 2020 01:01 AM (UTC)
Message
You need to use "w" rather than w.

eg.


ArrayBeach = {"w", "w", ... , "s"}



Your array is filled with the contents of variables n, s, e and w which are probably all nil (because they won't exist) and thus the array is full of nils, and effectively empty.

- Nick Gammon

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

Posted by Eammon Wright   (17 posts)  Bio
Date Reply #2 on Wed 30 Sep 2020 01:11 PM (UTC)
Message
Ok so that worked great, simple mistake.


ArrayBeach = {"w","w","w","w","w","n","e","e","e","e","e","n","w","w","w","w","w","n","e","e","e","e","e","n","w","w","w","w","w","n","e","e","e","e","e","s","s","s","s","s","s","s"}

DoAfter (5,ArrayBeach[1])
DoAfter (5,ArrayBeach[2])
DoAfter (5,ArrayBeach[3])
DoAfter (5,ArrayBeach[4])
DoAfter (5,ArrayBeach[5])
DoAfter (5,ArrayBeach[6])
DoAfter (5,ArrayBeach[7])
DoAfter (5,ArrayBeach[8])
DoAfter (5,ArrayBeach[9])
DoAfter (5,ArrayBeach[10])
DoAfter (5,ArrayBeach[11])
DoAfter (5,ArrayBeach[12])
DoAfter (5,ArrayBeach[13])
DoAfter (5,ArrayBeach[14])
DoAfter (5,ArrayBeach[15])
DoAfter (5,ArrayBeach[16])
DoAfter (5,ArrayBeach[17])
DoAfter (5,ArrayBeach[18])
DoAfter (5,ArrayBeach[19])
DoAfter (5,ArrayBeach[20])
DoAfter (5,ArrayBeach[21])
DoAfter (5,ArrayBeach[22])
DoAfter (5,ArrayBeach[23])
DoAfter (5,ArrayBeach[24])
DoAfter (5,ArrayBeach[25])
DoAfter (5,ArrayBeach[26])
DoAfter (5,ArrayBeach[27])
DoAfter (5,ArrayBeach[28])
DoAfter (5,ArrayBeach[29])
DoAfter (5,ArrayBeach[30])
DoAfter (5,ArrayBeach[31])
DoAfter (5,ArrayBeach[32])
DoAfter (5,ArrayBeach[33])
DoAfter (5,ArrayBeach[34])
DoAfter (5,ArrayBeach[35])
DoAfter (5,ArrayBeach[36])
DoAfter (5,ArrayBeach[37])
DoAfter (5,ArrayBeach[38])
DoAfter (5,ArrayBeach[39])
DoAfter (5,ArrayBeach[40])
DoAfter (5,ArrayBeach[41])
DoAfter (5,ArrayBeach[42])



This is just the beggining of it but this will run the whole map, however, it only does the first doafter. After that it speedruns the whole thing. Any thoughts on that problem?
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 01 Oct 2020 07:10 AM (UTC)
Message

You have heard of loops, haven’t you?

Although that will do them all after 5 seconds. Maybe you want:

That does each one 5 seconds apart.


- Nick Gammon

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

Posted by Eammon Wright   (17 posts)  Bio
Date Reply #4 on Thu 01 Oct 2020 11:47 AM (UTC)

Amended on Thu 01 Oct 2020 12:03 PM (UTC) by Eammon Wright

Message
That's Awesome, Yes sir. I was reading about loops, however, I was completley unsure if it was possible to have a loop set up, but stop when he comes across a creature, run the creature script, kill, wait and heal, then resume. Plus the loops were a little confusing for me.

Well I know it's possible, I just assumed it was wat too difficult for someone at my level, so Piece by piece it is.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 01 Oct 2020 10:41 PM (UTC)
Message

My loop won’t do that, but then neither would your long list of DoAfter do it either.

You need something we discussed elsewhere, where you build the directions into a “wait” alias, where you do something like:

  • Send a direction
  • Wait for a message indicating you have changed rooms, and see if there is a mob there (and which one it is)
  • Attack if necessary
  • Wait a few seconds perhaps
  • Advance to next direction in the list (wrapping at the end)
  • Go back to first point above.

- Nick Gammon

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

Posted by Eammon Wright   (17 posts)  Bio
Date Reply #6 on Fri 02 Oct 2020 11:29 AM (UTC)
Message
Yes sir. That's exactly what i'm looking to learn to do. So now that I have the bassic loop and map layout, what would be thr prooper way to pause that loop when I see one of those 3 creatures?
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #7 on Sat 03 Oct 2020 05:17 AM (UTC)
Message

Looking at your other thread about this you need to use the concepts there. Now I’m not going to write your bot for you, but this is the general structure:


- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


18,942 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.