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
➜ Stopping an Alias
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Seahawk
(2 posts) Bio
|
| Date
| Mon 12 Jul 2010 09:52 PM (UTC) |
| Message
| So, for multiple MUD's, I use the wait.time delay in Lua to create long aliases for performance.
---
Eg (one I plan to use to run an event)-
require "wait"
wait.make (function ()
Send ("event Capture the Flag is about to start! Listen up for the rules!")
wait.time ("5")
Send ("event One random person will be named the flag bearer to begin with. At all times, the flag bearer is allowed to attack anyone, but everyone else can only attack the flag bearer and not each other!")
wait.time ("15")
Send ("event To join the event, just type ARENA!")
wait.time ("5")
Send ("arena 100 desert 1")
wait.time ("3")
Send ("Everyone, I will now choose the flag bearer!")
end)
-----
So that takes approximately 30 seconds. Now, if something came up in those 30 seconds, I might want to stop the rest of the alias from proceeding.
Is there any way to do this without resorting to breaking all those parts into individual aliases and doing them all manually?
| | Top |
|
| Posted by
| Twisol
USA (2,257 posts) Bio
|
| Date
| Reply #1 on Mon 12 Jul 2010 09:57 PM (UTC) |
| Message
| require "wait"
wait.make (function ()
SetVariable("stop_alias_foo", "0")
Send ("event Capture the Flag is about to start! Listen up for the rules!")
wait.time ("5")
if GetVariable("stop_alias_foo") == "1"
return
end
Send ("event One random person will be named the flag bearer to begin with. At all times, the flag bearer is allowed to attack anyone, but everyone else can only attack the flag bearer and not each other!")
wait.time ("15")
if GetVariable("stop_alias_foo") == "1"
return
end
Send ("event To join the event, just type ARENA!")
wait.time ("5")
if GetVariable("stop_alias_foo") == "1"
return
end
Send ("arena 100 desert 1")
wait.time ("3")
if GetVariable("stop_alias_foo") == "1"
return
end
Send ("Everyone, I will now choose the flag bearer!")
end)
Probably the simplest/quickest approach. Write another alias that sets the stop_alias_foo variable to "1", and when this alias resumes, it'll see it and stop. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Mon 12 Jul 2010 10:21 PM (UTC) Amended on Mon 12 Jul 2010 10:24 PM (UTC) by Nick Gammon
|
| Message
| Yes indeed. And in the spirit of not repeating code, encapsulate all that:
require "wait"
wait.make (function ()
local function mywait (n)
wait.time (n)
return GetVariable("stop_alias_foo") == "1"
end -- mywait
-- clear the flag which stops the alias
SetVariable("stop_alias_foo", "0")
Send ("event Capture the Flag is about to start!...")
if mywait (5) then return end
Send ("event One random person will be named the flag bearer to begin with. ...")
if mywait (15) then return end
Send ("event To join the event, just type ARENA!")
if mywait (5) then return end
Send ("arena 100 desert 1")
if mywait (3) then return end
Send ("Everyone, I will now choose the flag bearer!")
end)
The function mywait does the pause, and tests the flag (which as Twisol said, you set up in another alias). If it matches, it returns true, which you use to break out of the main alias.
|
- 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 Mon 12 Jul 2010 10:23 PM (UTC) |
| Message
| | In fact in this case you could build the Send into mywait too, to make the main thing even shorter (just send down whatever it is you want to display). |
- 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.
14,037 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top