[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]  General
. . -> [Subject]  Speedwalking Script Solution for Lag?

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Speedwalking Script Solution for Lag?
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sun 27 Jul 2008 08:37 PM (UTC)  quote  ]
Message
It sounds very much to me like you are writing a bot, which most MUDs frown on.

I think I'll have to let you work out the details yourself here, but suffice to say that you need to make the script do what you, as a human would. That is, let the whole room description, including exits and list of mobs appear, and *then* work out whether to move on or kill something.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by DungBeetle   (3 posts)  [Biography] bio
Date Sun 27 Jul 2008 06:19 PM (UTC)  quote  ]
Message
argh, I had it working to an extent by switching the wait trigger from 'Obvious exits' to 'Health:', but that was with just one mob. As soon as I put in the other types I might encounter the script died and sends a only one command.

Could you show me how to make it "A * is standing here" and then make the if trigger off of wildcard [1] and Send ("kill" wildcards [1]? I've been messing with it but I can't seem to get the right syntax.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sat 26 Jul 2008 10:29 PM (UTC)  quote  ]
Message
OK I see it now.


Obvious exits:
sw
North - Too dark to tell
Southwest - Too dark to tell
A dog is here.
kill dog


As soon as it sees "Obvious exits:" it sends "sw", as you can see, as the script tells it to do.

Later it notices the dog - too late, as it has already moved.

I think you have to restructure a bit - the test for "A dog is here\.|A man is here\.|Obvious exits:" is all done after you have just sent the speedwalk. So you are pretty-much guaranteed that you have moved before you notice the dog.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by DungBeetle   (3 posts)  [Biography] bio
Date Sat 26 Jul 2008 05:27 PM (UTC)  quote  ]

Amended on Sat 26 Jul 2008 05:39 PM (UTC) by DungBeetle

Message
<aliases>
<alias
match="!*"
enabled="y"
send_to="12"
sequence="100"
>
<send>require "wait" -- load wait.lua

wait.make (function () --- coroutine below here

local lines = {}

sw = EvaluateSpeedwalk ("%1")

-- check for valid speedwalk

if string.sub (sw, 1, 1) == "*" then
ColourNote ("white", "red", string.sub (sw, 2))
return
end -- if

rex.new ("(.+)"):gmatch (sw,

-- build speedwalk lines into a table

function (m)
table.insert (lines, m)
end)

-- iterate the table, sending each line to the MUD

for i, line in ipairs (lines) do

-- send the speedwalk

Send (line)

-- now wait for an appropriate response

line, wildcards = wait.regexp ("^(A dog is here\.|A man is here\.|Obvious exits:)$")

-- check we didn't get told it was impossible

if string.sub (line, 3, 5) == "dog" then

Send ("kill dog")
line, wildcards = wait.regexp ("^(.* is DEAD!)$")

end -- if

if string.sub (line, 3, 5) == "man" then

Send ("kill man")
line, wildcards = wait.regexp ("^(.* is DEAD!)$")

end -- if


end -- of iterating through each speedwalk line

-- all done!


end) -- end of coroutine</send>
</alias>
</aliases>


It will move into the room with the mob and send the kill command. Then, while I'm approaching it to attack the next direction command is sent. It's like the "* is DEAD!"-wait doesn't matter.


I think the issue is right here:

Obvious exits:
sw
North - Too dark to tell
Southwest - Too dark to tell
A dog is here.
kill dog
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sat 26 Jul 2008 08:53 AM (UTC)  quote  ]
Message
I can't quite see what is wrong here. Can you post the whole alias? See:

http://mushclient.com/copying

Also paste the MUD output around when all this goes wrong.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by DungBeetle   (3 posts)  [Biography] bio
Date Fri 25 Jul 2008 05:26 PM (UTC)  quote  ]

Amended on Fri 25 Jul 2008 09:37 PM (UTC) by DungBeetle

Message
I'm trying to utilize this script to take me through an area, while maintaining the pause in case of lag, and to notice mobs . It should then attack them and wait until they're dead to resume the move.

Here's what I have so far, but it doesn't work.


require "wait" -- load wait.lua

wait.make (function () --- coroutine below here

local lines = {}

sw = EvaluateSpeedwalk ("%1")

-- check for valid speedwalk

if string.sub (sw, 1, 1) == "*" then
ColourNote ("white", "red", string.sub (sw, 2))
return
end -- if

rex.new ("(.+)"):gmatch (sw,

-- build speedwalk lines into a table

function (m)
table.insert (lines, m)
end)

-- iterate the table, sending each line to the MUD

for i, line in ipairs (lines) do

-- send the speedwalk

Send (line)

-- now wait for an appropriate response

line, wildcards = wait.regexp ("^(A dog is here\.|A man is here\.|Obvious exits:)$")

-- check we didn't get told it was impossible

if string.sub (line, 3, 5) == "dog" then

Send ("kill dog")
line, wildcards = wait.regexp ("^(.* is DEAD!)$")

end -- if

if string.sub (line, 3, 5) == "man" then

Send ("kill man")
line, wildcards = wait.regexp ("^(.* is DEAD!)$")

end -- if


end -- of iterating through each speedwalk line

-- all done!


end) -- end of coroutine



EDIT: I should mention what it does do. The walk works, and the attack works but it won't wait to kill them before pushing more speedwalk commands.h
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Wed 26 Mar 2008 03:33 AM (UTC)  quote  ]
Message
You want to "and" them, as you are testing for not the condition. In other words, we fail if it not obvious exits AND not dark.


  -- check we didn't get told it was impossible

  if string.sub (line, 1, 14) ~= " Obvious exits" and 
     string.sub (line, 1, 10) ~= "It is dark" then

    ColourNote ("white", "red", "Speedwalk cancelled")
    return  -- give up
  end -- if


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by RichKK   (25 posts)  [Biography] bio
Date Wed 26 Mar 2008 02:39 AM (UTC)  quote  ]

Amended on Wed 26 Mar 2008 03:17 AM (UTC) by RichKK

Message
The lag isn't so bad anymore, it just has its moments, but what can I expect, 12 years in and the MUD is still in beta. The big leap was upgrading to version 4.19, version 3.32 ought to be enough MUSHclient for anybody <g>

I love this script and really made use of the old version! It was versatile enough to use for so many different situations that require waiting for a response before sending the next command in a sequence; just perfect. Thanks a ton.

Can you just show me how to include more options for the 'if... then... ~=...', I'd like to keep sending directions even I get "It is dark"

Quote:

line, wildcards = wait.regexp ("^( Obvious exits: .*\.|\>You can't go that way\.|You can't go that way\.|It is dark\.)$")

-- check we didn't get told it was impossible

if string.sub (line, 1, 18) ~= " Obvious exits" (AND WHAT I'D LIKE TO INCLUDE IS) or string.sub (line, 1, 10) ~= "It is dark" then
ColourNote ("white", "red", "Speedwalk cancelled")
return -- give up
end -- if




[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 25 Mar 2008 08:08 PM (UTC)  quote  ]
Message
MUD still slow, huh, four years later? :-)

Nowadays the "wait" functionality is in a wait.lua file that comes with MUSHclient. I assume you are using a reasonably recent version?

This updated version should work (maybe you need to adjust the exits detection). It is slightly simpler than the old one, and uses wait.lua to provide the waiting functionality:


<aliases>
  <alias
   match="!*"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

require "wait"  -- load wait.lua

wait.make (function ()  --- coroutine below here

local lines = {}

sw = EvaluateSpeedwalk ("%1")

-- check for valid speedwalk

if string.sub (sw, 1, 1) == "*" then
  ColourNote ("white", "red", string.sub (sw, 2))
  return
end -- if

rex.new ("(.+)"):gmatch (sw, 

-- build speedwalk lines into a table

function (m) 
  table.insert (lines, m)
end)

 -- iterate the table, sending each line to the MUD

 for i, line in ipairs (lines) do

  -- send the speedwalk

   Send (line) 

  -- now wait for an appropriate response

  line, wildcards = wait.regexp ("^(Exits: .*\.|Alas, you cannot go that way\.)$")

  -- check we didn't get told it was impossible

  if string.sub (line, 1, 5) ~= "Exits" then
    ColourNote ("white", "red", "Speedwalk cancelled")
    return  -- give up
  end -- if

  end  -- of iterating through each speedwalk line

  -- all done!

  ColourNote ("white", "blue", "speedwalk done")

end)  -- end of coroutine

</send>
  </alias>
</aliases>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by RichKK   (25 posts)  [Biography] bio
Date Tue 25 Mar 2008 01:35 PM (UTC)  quote  ]

Amended on Tue 25 Mar 2008 01:42 PM (UTC) by RichKK

Message
Sorry for dredging this thread up (I'm the OP, lost my password) but I've been redoing my aliases, timers and triggers in Lua and with Mr Gammon's alias I get this error message:

Quote:

Error number: 0
Event: Run-time error
Description: [string "Alias: "]:48: [string "Alias: "]:32: attempt to call global 'waitforregexp' (a nil value)

stack traceback:

[C]: in function 'assert'

[string "Alias: "]:48: in main chunk
Called by: Immediate execution


For example "! 2n" sends "n" but then gives the above error message

First I thought I wasn't matching the exits properly but I get the same error message even when I get the movement failed "Alas, you cannot go that way." message.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sat 15 Oct 2005 09:25 PM (UTC)  quote  ]
Message
The ! is an alias for my special speedwalk. See the alias? It matches on "!*" which means "!" followed by anything.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Peeka   (5 posts)  [Biography] bio
Date Sat 15 Oct 2005 01:16 AM (UTC)  quote  ]
Message
Okay, hmm, I think I understand all of this.

Will the '!' work in front of the path alias?
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Fri 14 Oct 2005 02:35 AM (UTC)  quote  ]

Amended on Fri 14 Oct 2005 07:07 AM (UTC) by Nick Gammon

Message
I've tried to do a speed walk that waits for exits a different way, to make it simpler. The alias below should accomplish that for you, providing you make Lua your scripting language, and the file "exampscript.lua" your script file (see the Scripts tab in the world configuration).



<aliases>
  <alias
   match="!*"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>do local t = coroutine.create (function (t)

local lines = {}

sw = EvaluateSpeedwalk ("%1")

-- check for valid speedwalk

if string.sub (sw, 1, 1) == "*" then
  ColourNote ("white", "red", string.sub (sw, 2))
  return
end -- if

rex.new ("(.+)"):gmatch (sw, 

-- build speedwalk lines into a table

function (m) 
  table.insert (lines, m)
end)

 -- iterate the table, sending each line to the MUD

 for i, line in ipairs (lines) do

  -- send the speedwalk

   Send (line) 

  -- now wait for an appropriate response

  line, wildcards = waitforregexp (t, 
          "^(Exits: .*\.|Alas, you cannot go that way\.)$")

  -- check we didn't get told it was impossible

  if string.sub (line, 1, 5) ~= "Exits" then
    ColourNote ("white", "red", "Speedwalk cancelled")
    return  -- give up
  end -- if

  end  -- of iterating through each speedwalk line

  -- all done!

  ColourNote ("white", "blue", "speedwalk done")

end) assert (coroutine.resume (t, t)) end

</send>
  </alias>
</aliases>



What this does is make an alias where you type "!" followed by the speedwalk string, and it then sends the lines one by one until the speedwalk is finished. It doesn't send a new line until an "Exits:" line arrives, thus making sure that each line is sent only when ready.

Eg. You type: ! 3e 2n

It also tests for the "error" message "Alas, you cannot go that way." and if received cancels the speedwalk, on the basis that you must have wandered into somewhere unexpected, and sending further speedwalks will be a waste of time.

If the "error" line is different you will need to change the line above to match what your MUD sends, escaping special characters like periods with a backslash, as is done above.

You may also need to modify the "Exits:" part above if your MUD sends something different, like "Obvious exits" or something similar.

[EDIT]

Modified to check for valid speedwalk string.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Peeka   (5 posts)  [Biography] bio
Date Thu 13 Oct 2005 10:20 PM (UTC)  quote  ]
Message
*bump*

I am new to using MUSHclient and know little about scripting.

I have trouble with lag and speed walking too, how do I use the scripts posted above to check for the next line of exits before following the next direction?
[Go to top] top

Posted by Karl_Newbie   USA  (23 posts)  [Biography] bio
Date Wed 28 Apr 2004 04:10 AM (UTC)  quote  ]
Message
Ahh got it. I'm reading the help on Regular Expressions now. Thanks again.
[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.


4,818 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

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