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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ AFK plugin

AFK plugin

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


Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Sat 08 Oct 2005 01:26 AM (UTC)
Message
This plugin, written in Lua, tries to handle going AFK automatically, in case your MUD doesn't do it for you.

What it does is set up a timer, defaulting to 5 minutes, and when the timer fires, sends "afk" to the MUD. Whenever you type something, which is caught by OnPluginCommand, the timer is reset, to make the 5 minute timer start again.

A bit of testing revealed that the first version was a bit fiddly to get right, as it was possible for the MUD, and the plugin, to be out of step. This was because SMAUG uses "afk" to turn AFK on, and "afk" again to turn it back off.

To work around this the plugin detects the string "You are now afk." to resynchronise its timer.

To customise, change the first few lines directly below to be the AFK command, the number of minutes and seconds you want to wait before being AFK, and the exact message the MUD sends when you go AFK and back again.

The plugin does a Note in salmon colour to notify you when it thinks you are AFK, and not AFK, so you can see when it is working.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient [
  <!ENTITY afk_command "afk" > 
  <!ENTITY timer_mins "5" > 
  <!ENTITY timer_secs "0" > 
  <!ENTITY afk_message "You are now afk." > 
  <!ENTITY not_afk_message "You are no longer afk." > 
]>

<!--

Customising (change above entities) ...

Change "afk_command" to whatever sets you AFK.
  Default: afk
   
Change "timer_mins" to be the number of minutes before you are AFK.
	Default: 5 minutes
	
Change "timer_secs" to be the number of seconds before you are AFK.
	Default: 0 seconds

In other words, to be AFK after 2.5 minutes, timer_mins would be 2, and 
timer_secs would be 30.

-->

<!-- Saved on Saturday, October 08, 2005, 10:37 AM -->
<!-- MuClient version 3.66 -->

<!-- Plugin "AFK_timer" generated by Plugin Wizard -->

<muclient>
<plugin
   name="AFK_timer"
   author="Nick Gammon"
   id="4d167d47cac26fb36e161e48"
   language="Lua"
   purpose="Sends AFK to the MUD when 5 minutes elapse"
   date_written="2005-10-08 10:32:50"
   requires="3.52"
   version="1.0"
   >
<description trim="y">
<![CDATA[
After the specified interval (default 5 minutes) elapse, sends "afk" to the MUD.
]]>
</description>

</plugin>

<!--  Timers  -->

<timers>
  <timer name="afk_timer" 
         second="&timer_secs;"  
         minute="&timer_mins;"  
         send_to="12"    
         enabled="y"
>
  <send>
    ColourNote ("salmon", "", "You are now AFK.")
    Send ("&afk_command;")
    EnableTimer ("afk_timer", 0)
  </send>
  </timer>
</timers>

<!--  Triggers -->

<triggers>
  <trigger
   enabled="y"
   match="&not_afk_message;"
   send_to="12"
  >
  <send>
    FixTimer ()  -- make sure timer is back on
  </send>
  </trigger>
</triggers>

<triggers>
  <trigger
   enabled="y"
   match="&afk_message;"
   send_to="12"
  >
  <send>
    EnableTimer ("afk_timer", 0) -- make sure timer is off
  </send>
  </trigger>
</triggers>


<!--  Script  -->


<script>
<![CDATA[

-- when they type something, reset AFK status

function OnPluginCommand (sText)
  FixTimer ()
  return true  -- process the command
end

-- when you connect to the MUD, presumably you are not AFK

function OnPluginConnect ()
  FixTimer ()
end

-- shared routine to handle turning AFK off

function FixTimer ()
  if GetTimerOption ("afk_timer", "enabled") == 0 then
    ColourNote ("salmon", "", "You are no longer AFK.")
  end

-- turn timer back on
  EnableTimer ("afk_timer", 1)

-- make sure the full time interval elapses
  ResetTimer ("afk_timer")

end
]]>
</script>

</muclient>


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by DanielNicolai   USA  (3 posts)  Bio
Date Reply #1 on Sun 16 Oct 2005 08:54 PM (UTC)
Message
May I suggest an addition to this, I know this is possible with HTML (actualy it's an annoying thing that can happen, but we will use it for good today). Perhaps have it so that if the screen is not the main screen you go AFK also. So if I go out to check my mail for a few minutes I will autoAFK when I click Firefox. It would work for anything though, just make it so that if it's not on top, we go AFK automaticly.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 16 Oct 2005 09:25 PM (UTC)
Message
You could use the "lost focus" world event to discover when you are no longer on your main screen, however that could be a bit annoying - every time you open a dialog box it would think you have gone AFK.

Probably just using this plugin with a fairly short delay would be enough.

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


13,741 views.

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.