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 ➜ Building pauses into scripts

Building pauses into scripts

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


Pages: 1  2 

Posted by Darcon   (26 posts)  Bio
Date Reply #15 on Thu 29 Nov 2012 10:29 PM (UTC)
Message
Thank you for explaining it to me Nick. I was really at a loss on that one...then again I am pretty new to all this.
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #16 on Tue 30 Apr 2024 06:25 AM (UTC)

Amended on Tue 30 Apr 2024 06:30 AM (UTC) by Nick Gammon

Message
Following on from a suggestion by a user, wait.make() has now been enhanced to allow you to pass arguments to the function that is called as a coroutine.

This is especially useful if you want to put a function in your script file and share it between various aliases or triggers.

For example, you could pass your wildcards from an alias down to the called function which executes in the "wait" environment, like this:


require "wait"
function my_alias(name, line, wildcards)
    wait.make(countdown, wildcards)
end  -- end of my_alias


And then to process that function call:


function countdown(wildcards)
  local count = tonumber (wildcards [1])

  for i = 1, count do
     Note (i)
     wait.time (1)  -- wait a second
  end -- for

end  -- end of countdown



To obtain this functionality, you can download the enhanced version of wait.lua from https://github.com/nickgammon/mushclient/blob/master/lua/wait.lua and replace the wait.lua file in your "lua" subdirectory of your MUSHclient installation.

Any number of arguments can be passed to the function in this way.

- 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.


116,579 views.

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

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.