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
➜ General
➜ Speedwalk Queue
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| JoeScripter
(12 posts) Bio
|
| Date
| Wed 12 Oct 2005 03:29 PM (UTC) |
| Message
| Hello!
I've recently stumbled across MUSHclient thanks to a co-worker, and have suddenly found a renewed interest to play a mud I used to play ages ago.. now that scripting is a part of it, anyways :)
The Queue feature (for speedwalking and otherwise) seems like an extremely useful one, and is finding it's way into more and more of my scripting.. but there seems to be a slight limitation on it. That is, it would be nice if there was some way to execute a function after the queue has finished. It seems that the queue is set to "SendTo world", as even if I try the macro trick of coding an alias to fit a command, and Queueing the alias, it just seems to bypass the command parser and gets sent directly to the mud.
Am I missing something? Is there a way to do this? or perhaps this thread should have been posted in the "Feature requests" forum..
Anyways for the time being I have been using work arounds to get the functionality I want out of my scripts, but I can't help but wonder if there is any more direct way to do this :) | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Wed 12 Oct 2005 09:30 PM (UTC) |
| Message
| You want to send a sequence of commands to the MUD, with pauses between them, and then execute some script command?
The speedwalk queue is probably not the most flexible way of doing this. Take a look at this post:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4956
In it I describe a method of using timers and the Lua thread model to simply do things with pauses, inside a script. This would let you send things, with variable delays between them if wanted (eg. 1 second, 3 seconds, 2 seconds), and then execute script commands between and after each one.
I have modified the example at the end of that post to show doing that, with a loop in the middle, to show how the stuff you send can be scripted into a loop.
<aliases>
<alias
match="test2"
enabled="y"
send_to="12"
sequence="100"
>
<send>
do local t = coroutine.create (function (t)
Note ("Before my sends ...")
wait (t, 1)
for i = 1, 5 do
Send ("think I am thinking of the number " .. i)
wait (t, 0.3)
end
Note ("cooldown of 2 seconds ...")
wait (t, 2)
Note ("Done")
end) assert (coroutine.resume (t, t)) end
</send>
</alias>
</aliases>
The only thing you need to make this work is to have Lua as your scripting language and the supplied file "exampscript.lua" defined as your script file. This provides the support routines needed to make the "wait" command work.
If you have already chosen a different scripting language, and don't want to change, then make a plugin using the Lua language to accomplish this, and put the support routines from that file into the plugin. Specifically, you want from the wait_table declaration down to the end of the function wait. In fact, the exact script code that is in the post thread I gave above.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| JoeScripter
(12 posts) Bio
|
| Date
| Reply #2 on Thu 13 Oct 2005 04:26 AM (UTC) Amended on Thu 13 Oct 2005 04:30 AM (UTC) by JoeScripter
|
| Message
| Nick! Thanks very much for your response.. oh and your software kicks ass btw :)
TBH I was a little intimidated by your Lua code however, even though it seems quite simple.. In fact, I don't know what's more embarassing, the fact that I wasted a bunch of time trying this "thread" idea out in Perl land first(seeing as how I'm much more familiar w/ Perl..), or that I finally came back to be clued in by merely reformatting the last line to be the following 4 lines:
end)
assert (coroutine.resume (t, t))
Note ("Whoa!")
end
I now see that you're just defining an anonymous function to pass as the parameter to coroutine.create. That's pretty cool :) Too bad my knowledge of Lua doesn't come close to Perl.. I'm not sure if I want to port my scripts over to it.. or if I should try to work on keeping things neat enough for them to co-exist. I just can't see myself ditching Perl's amazing text processing functionality :) That being said, I get some weird runtime errors when trying even simple examples gotten from webpages in an attempt to use Perl's threading modules.. so I guess Lua is where this functionality will stay! | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Thu 13 Oct 2005 05:23 AM (UTC) |
| Message
| Yes, the anonymous functions are a pretty cool part of Lua. You can use them in situations where you need to pass something like a sort comparator to a sort routine.
If you want to use Perl, there is nothing really stopping you using CallPlugin to have the alias (in Lua) call a script in Perl, in another plugin, if you have a requirement for extensive text processing.
However Lua does have some pretty good text support, and the extension provided by MUSHclient to expose the PCRE regular expression library helps with fairly complex pattern matching. See:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4905
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| JoeScripter
(12 posts) Bio
|
| Date
| Reply #4 on Thu 13 Oct 2005 01:34 PM (UTC) Amended on Thu 13 Oct 2005 01:37 PM (UTC) by JoeScripter
|
| Message
| I admit there are definitely some additionals pros to Lua.. such as the way you've defined the var metatable to make interacting with MUSHclient variables more streamlined, or the way you can call MUSHclient functions without having to worry about fiddling around with a seperate ($world) object!
Ah well. Guess it's time to learn another language :) I've started going through some Lua documentation, and so far it looks pretty interesting!
Thanks again for your help Nick! | | 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.
20,552 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top