<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient[
  <!ENTITY trigger_match 
   "*You raised a level!" > 
]>
<!-- Saved on Monday, August 11, 2003, 7:34 AM -->
<!-- MuClient version 3.42 -->

<!-- Plugin "Level_Timer" generated by Plugin Wizard -->

<!--
Change the entity above to reflect the message you get when you level.
-->

<muclient>
<plugin
   name="Level_Timer"
   author="Nick Gammon"
   id="5f4928cc5f9e2306d3b0a361"
   language="VBscript"
   purpose="Displays how long it take you to level"
   save_state="y"
   date_written="2003-08-11 07:32:28"
   requires="3.24"
   version="1.0"
   >
<description trim="y">
<![CDATA[
When installed, this plugin will display how long it takes you to level.
]]>
</description>

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   custom_colour="7"
   enabled="y"
   match="&trigger_match;"
   script="OnLevel"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>
</triggers>

<!--  Script  -->


<script>
<![CDATA[
sub OnLevel (name, line, wildcards)
dim oldtime
dim newtime
dim days, hours, minutes
dim s1, s2, s3
dim msg

  oldtime = GetVariable ("last_level_time")

'
'  First time - just remember when we levelled

'
  if IsEmpty (oldtime) or not IsDate (oldtime) then
    SetVariable "last_level_time", now
    Note "Level time noted."
    exit sub
  end if

'
'  Find total minutes it took to level
'
  minutes = DateDiff ("n", CDate (oldtime), Now)

'
'  Convert to days, hours, minutes
'

  days = Fix (minutes / 1440)
  minutes = minutes - (days * 1440) ' remainder
  hours = Fix (minutes / 60)
  minutes = minutes - (hours * 60) ' remainder

'
'  Add "s" if plural
'
  s1 = "s"
  s2 = "s"
  s3 = "s"
  if days = 1 then s1 = ""
  if hours = 1 then s2 = ""
  if minutes = 1 then s3 = ""

'
'  Make message
'

  msg = "Time to level = " _
        & days & " day" & s1 & ", " _
        & hours & " hour" & s2 & ", " _
        & minutes & " minute" & s3 & "."

  ColourNote "white", "blue", msg
  SetVariable "last_level_time", now

end sub

]]>
</script>


</muclient>
