JMC Clock Script by p(Eloril) This is a much-needed clock script for JMC. It is very accurate and is only off by a second after a long session. It uses the VBScript timing function and not the JMC timing function, so no more spammy #TICK messages. The directions are as follows: Examine a clock to set the time. ClockSet(hour, min, am/pm) sets the time manually. ti - Displays current time. sti - Says the time. tti player_name - Tells player_name the time. nti - Narrates the time. Paste the following code into your .set file: #nop -- Clock Script -- #alias {ti} {#script ClockShowTime 0,""} #alias {sti} {#script ClockShowTime 1,""} #alias {tti} {#script ClockShowTime 2,"%1"} #alias {nti} {#script ClockShowTime 3,""} #action {The current time is %1:%2 %3.} {#script ClockSet %1,%2,"%3"} Paste the following code into settings\commonlib.scr: '**************************************** 'CLOCK SCRIPT by Eloril 'Works by taking the time difference 'from when the clock is set to when it is 'checked and converting that difference 'to the standard time format. ' 'Examine a clock to set the time, or use 'ClockSet(hour, min, am/pm) to set the time. ' 'ti - Displays current time. 'sti - Says the time. 'tti - Tells someone the time. 'nti - Narrates the time. ' 'Thanks to Rashnak for some perfect 'examples of VBScript and commenting 'conventions. '**************************************** Dim tMume, tReal, tHour, tAp, tSet, ClockIsSet Const Client = 0, Say = 1, Tell = 2, Narrate = 3 tSet = 0 ClockIsSet = False '**************************************** 'CLOCK SCRIPT: ClockSet(hour, min, ap) 'Sets the clock. '**************************************** Sub ClockSet(hour, min, ap) Dim time If ClockIsSet Then Exit Sub 'Convert current mume time to seconds tMume = TimeToSec(hour, min, ap) 'Get current real time in seconds tReal = Int(Timer) 'Replace mume time message jmc.DropEvent time = SecToTime(tMume) jmc.showme "You set your watch to " & time & "." ClockIsSet = True End Sub '**************************************** 'CLOCK SCRIPT: ClockShowTime() 'Shows the current mume time. '**************************************** Sub ClockShowTime(mode, player) Dim time 'A little Easter egg If not ClockIsSet Then If tSet = 0 Then jmc.showme VBCrLf & "Your watch doesn't seem to be set." If tSet = 1 Then jmc.showme VBCrLf & "Your watch mockingly flashes 12:00 am." If tSet = 2 Then jmc.showme VBCrLf & "You rattle your watch a bit, but to no prevail." tSet = tSet + 1 If tSet > 2 Then tSet = 0 Exit Sub End If 'When telling someone the time, check if player specified If mode = TELL and player = "" Then jmc.showme VBCrLf & "To whom shall you tell the time?" Exit Sub End If 'Convert and show the time time = SecToTime(ClockGetDif) If mode = Client Then jmc.showme VBCrLf & "According to your watch it's " & time & "." If mode = Say Then jmc.send "emote quickly glances down and says 'It's " & time & ".'" If mode = Tell Then jmc.send "tell " & player & " The current time is " & time & "." If mode = Narrate Then jmc.send "narrate The current time is " & time & "." End Sub '**************************************** 'CLOCK SCRIPT: ClockGetDif() 'Calculates difference in seconds from 'the time the clock was set to now. '**************************************** Function ClockGetDif() Dim tDif, tCur 'Get elapsed time in seconds tDif = Int(Timer) - tReal 'If real time is past midnight... If tDif < 0 Then tDif = (86400 - tReal) + Int(Timer) End If 'Add difference to mume time to get current time tCur = tMume + tDif 'Make sure the difference is within 24 minutes While tCur > 1440 tCur = tCur - 1440 Wend ClockGetDif = tCur End Function '**************************************** 'CLOCK SCRIPT: TimeToSec(hour, min, ap) 'Converts hours and minutes to seconds. '**************************************** Function TimeToSec(hour, min, ap) Dim sec sec = (hour * 60) + min If ap = "am" and hour = 12 Then sec = sec - 720 If ap = "pm" and hour < 12 Then sec = sec + 720 TimeToSec = sec End Function '**************************************** 'CLOCK SCRIPT: SecToTime(sec) 'Converts seconds to hours and minutes. 'The result is returned as a string. '**************************************** Function SecToTime(sec) Dim time, hour, min, ap 'Get hours and minutes hour = sec \ 60 min = sec Mod 60 'Determine am or pm If hour <= 11 Then ap = "am" If hour >= 12 Then ap = "pm" If hour = 24 Then ap = "am" If hour = 0 Then hour = 12 If hour > 12 Then hour = hour - 12 'Put together hours, minutes, and am/pm If min >= 10 Then time = hour & ":" & min & " " & ap Else time = hour & ":0" & min & " " & ap End If SecToTime = time End Function