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
➜ Lua
➜ Passing command through idle-timer alias
Passing command through idle-timer alias
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Dragonatorul
(2 posts) Bio
|
Date
| Fri 08 Jan 2016 09:13 PM (UTC) |
Message
| Hello,
I'm trying to set up a way to be notified if I've been idle for 15, 20, and 25 minutes.
The way I thought of is to set up an alias that captures every command I send to the world and passes it through to the world, while at the same time creating 3 timers which set off a function that plays a "ding". However, I'm having trouble with the passing the command through to the world.
If I setup an alias to capture
and set up the body of the alias with the function:
If I set it to send this to the world and type the command look it sends this to the world:
If I set it to send to Script it sends this to the world:
I'm stumped because it seems to capture it properly when sending to the world, but not when sending to the script, then passing back to the world. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Fri 08 Jan 2016 09:48 PM (UTC) Amended on Sat 09 Jan 2016 02:36 AM (UTC) by Nick Gammon
|
Message
| You could make a small plugin that uses the OnPluginCommand callback to find when you actually typed a command.
Something like the one below:
 |
To save and install the IdleWarning plugin do this:
- Copy between the lines below (to the Clipboard)
- Open a text editor (such as Notepad) and paste the plugin into it
- Save to disk on your PC, preferably in your plugins directory, as IdleWarning.xml
- Go to the MUSHclient File menu -> Plugins
- Click "Add"
- Choose the file IdleWarning.xml (which you just saved in step 3) as a plugin
- Click "Close"
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="IdleWarning"
author="Nick Gammon"
id="9c9c760caf80e43893bb7b70"
language="Lua"
purpose="Warns when you are idle"
date_written="2016-01-09 08:22:56"
requires="4.90"
version="1.0"
>
</plugin>
<!-- Timers -->
<timers>
<timer
name="timer1"
enabled="y"
minute="15"
send_to="1"
script="OnIdleTimeout"
>
</timer>
<timer
name="timer2"
enabled="y"
minute="20"
send_to="1"
script="OnIdleTimeout"
>
</timer>
<timer
name="timer3"
enabled="y"
minute="25"
send_to="1"
script="OnIdleTimeout"
>
</timer>
</timers>
<!-- Script -->
<script>
<![CDATA[
playedDing = {} -- empty table
lastCommand = os.time ()
function OnPluginCommand ()
ResetTimers () -- all timers start again
playedDing = {} -- reset table of played dings
lastCommand = os.time ()
return true -- process this command
end -- OnPluginCommand
function OnIdleTimeout (name)
-- don't play it twice
if playedDing [name] then
return
end -- if
playedDing [name] = true
PlaySound (0, "ding.wav")
minutes = (os.time () - lastCommand) / 60
ColourNote ("yellow", "", string.format ("WARNING: You have been idle for %i minutes now.", minutes))
end -- OnIdleTimeout
]]>
</script>
</muclient>
Note that the sound file should be in the "sounds" directory under the MUSHclient install folder.
The only file type supported is a .wav file, as follows:
* 16-bit
* 22.05 KHz
* PCM (ie. uncompressed)
* Mono or Stereo |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #2 on Sat 09 Jan 2016 04:52 AM (UTC) Amended on Sat 09 Jan 2016 04:53 AM (UTC) by Nick Gammon
|
Message
|
Quote:
... and set up the body of the alias with the function:
Send(%1)
Related to your question:
It would have worked better as:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Dragonatorul
(2 posts) Bio
|
Date
| Reply #3 on Sat 09 Jan 2016 04:19 PM (UTC) |
Message
|
Nick Gammon said:
You could make a small plugin that uses the OnPluginCommand callback to find when you actually typed a command.
Something like the one below:
Did you just write the plugin I was trying to write myself? You are AWESOME! Thank you!
Also thanks for clearing that lua value quote up for me. I have very little experience in Lua, having mostly worked with Java so far, but am learning as I go thanks to your client.
I'd also like to say you did an awesome job with the MUSHclient and thank you for making it available. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #4 on Sun 10 Jan 2016 06:33 AM (UTC) |
Message
|
Quote:
Did you just write the plugin I was trying to write myself?
Yes I did. I thought other people might find it useful too. :) |
- 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,860 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top