[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Stopping an Alias
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Stopping an Alias

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


Posted by Seahawk   (2 posts)  [Biography] 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?
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] 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
[Go to top] top

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

Posted by Nick Gammon   Australia  (21,493 posts)  [Biography] 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
[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.


2,195 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]