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

Gammon Software Solutions forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  AFK plugin

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: AFK plugin
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Nick Gammon   Australia  (18,801 posts)  [Biography] bio   Forum Administrator
Date Sun 16 Oct 2005 09:25 PM (UTC)  quote  ]
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
[Go to top] top

Posted by DanielNicolai   USA  (3 posts)  [Biography] bio
Date Sun 16 Oct 2005 08:54 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,801 posts)  [Biography] bio   Forum Administrator
Date Sat 08 Oct 2005 01:26 AM (UTC)  quote  ]
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
[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,274 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]