You can't shove the OnPluginSent function into something that a timer calls and hope for it to work. (Well, you can hope, but it won't!).
Writing a plugin is quite easy, there is a plugin wizard for that.
Here is a simple plugin that does what you want:
To save and install the
Do_Something_When_Idle plugin do this:
- Copy the code below (in the code box) to the Clipboard
- Open a text editor (such as Notepad) and paste the plugin code into it
- Save to disk on your PC, preferably in your plugins directory, as
Do_Something_When_Idle.xml
- The "plugins" directory is usually under the "worlds" directory inside where you installed MUSHclient.
- Go to the MUSHclient File menu -> Plugins
- Click "Add"
- Choose the file
Do_Something_When_Idle.xml (which you just saved in step 3) as a plugin
- Click "Close"
- Save your world file, so that the plugin loads next time you open it.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="Do_Something_When_Idle"
author="Nick Gammon"
id="3dd3eb0ecf9eb5b183c98fec"
language="Lua"
purpose="Send a sleep command if you are idle"
date_written="2018-03-27 15:34:55"
requires="4.90"
version="1.0"
>
<description trim="y">
<![CDATA[
Sends "sleep" if you are idle for 5 minutes.
]]>
</description>
</plugin>
<!-- Timers -->
<timers>
<timer name="IdleSense"
enabled="y"
minute="5"
second="0.00"
send_to="12"
group="NecroM" >
<send>
if not timerFired then
Execute ("sleep")
timerFired = true
end -- if not already done it
</send>
</timer>
</timers>
<!-- Script -->
<script>
<![CDATA[
function OnPluginSent (sText)
ResetTimer ("IdleSense")
timerFired = false
end
]]>
</script>
</muclient>
Testing showed an interesting problem. The timer would keep firing every 5 minutes, attempting to put you to sleep again. So what this does is remember when you send the "sleep" command so you don't do it again. This "remembering" is cleared when you send something new.
This has to be done
after sending "sleep" otherwise that counts as doing something new.