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 ➜ Timer plugin

Timer plugin

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


Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Wed 03 Mar 2004 08:40 PM (UTC)

Amended on Wed 03 Mar 2004 08:41 PM (UTC) by Nick Gammon

Message
The plugin below calculates elapsed time from when you connected and shows it in the status bar. It can be reset by typing "timerreset" so you can use it for timing any event (eg. you have 10 minutes to find your corpse).



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, March 04, 2004, 7:32 AM -->
<!-- MuClient version 3.42 -->

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

<muclient>
<plugin
   name="Timer"
   author="Nick Gammon"
   id="cc98cbe576474a19d1715a02"
   language="VBscript"
   purpose="Shows elapsed time in status bar"
   date_written="2004-03-04 07:29:18"
   requires="3.30"
   version="1.0"
   >
<description trim="y">
<![CDATA[
This plugin displays time connected in the status bar. 
It can be reset to zero when you like.

The time is shown as hours and minutes (eg. 4h 22m) - if you are connected for 
more than a day then it will show more than 24 hours. 
You could amend it slightly to change that if you wanted.

Commands
--------

timerreset  - reset timer to zero
Timer:help  - show this help
]]>
</description>

</plugin>


<!--  Aliases  -->

<aliases>
  <alias
   script="TimerToZero"
   match="resettimer"
   enabled="y"
   send_to="2"
   sequence="100"
  >
  <send>Timer reset.</send>
  </alias>
</aliases>

<!--  Timers  -->

<timers>
  <timer name="StatusBarTimer" script="ElapsedTimer" enabled="y" second="30" >

  </timer>
</timers>

<!--  Script  -->


<script>
<![CDATA[
'
'  Timer showing when we last connected
'

dim tConnected

tConnected = Now

'
' This world has been connected (to the MUD)
'
sub OnPluginConnect
  tConnected = Now
  Call ElapsedTimer ("StatusBarTimer")
end sub

'
' Plugin has been installed
'
sub OnPluginInstall
  Call OnPluginConnect
end sub

'
'  Called by alias to zero timer
'
Sub TimerToZero (sName, sLine, wildcards)
  Call OnPluginConnect
End Sub

'
'  Called when timer fires
'
Sub ElapsedTimer (sName)

dim Minutes, Hours

'
'  Calculate how long in minutes
'
  Minutes = DateDiff ("n", tConnected, Now)

'
'  Convert to hours and minutes
'
  Hours = Int (Minutes / 60)	
  Minutes = Minutes - (Hours * 60)

'
'  Update status bar
'
  SetStatus "Timer: " & Hours & "h " & Minutes & "m"
End Sub

'
' Plugin is being removed (closed)
'
sub OnPluginClose
  SetStatus "Ready"
end sub

]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="Timer:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
Sub OnHelp (sName, sLine, wildcards)
  world.Note world.GetPluginInfo (world.GetPluginID, 3)
End Sub
]]>
</script> 

</muclient>

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


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