Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
hoot
Newbie


Joined: 30 Apr 2004
Posts: 6
Location: USA

PostPosted: Mon May 29, 2006 5:13 pm   

Mume clock
 
Lots use this script on mume, any know how to get it to work with zmud?

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
_________________
It's not the years, hony, it's the mileage.
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Tue May 30, 2006 12:29 am   
 
Code:
#CLASS System
#ALIAS atconnect {init}
#CLASS {MumeClock}
#TRIGGER {The current time is %1:%2 %3.} {#mss {ClockSet %1, %2, ~"%3~"}}
#ALIAS init {#SS "VBScript"}
#ALIAS ti {#mss {ClockShowTime "Client",~"~"}}
#ALIAS sti {#mss {ClockShowTime "Say",~"~"}}
#ALIAS tti {#mss {ClockShowTime "Tell", ~"%1~"}}
#ALIAS nti {#mss {ClockShowTime "Narrate",~"~"}}
#CLASS 0
#EDIT init
Copy and paste the above into the command line in zMUD and press return. The settings editor will open and put you in edit mode for the alias init, copy and paste the below code into it and press the save button.
Code:
'****************************************
'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)
zmudcommand 175, array("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 zmudcommand 175, array(VBCrLf & "Your watch doesn't seem to be set.")
If tSet = 1 Then zmudcommand 175, array(VBCrLf & "Your watch mockingly flashes 12:00 am.")
If tSet = 2 Then zmudcommand 175, array(VBCrLf & "You rattle your watch a bit, but to no avail.")
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
zmudcommand 175, array(VBCrLf & "To whom shall you tell the time?")
Exit Sub
End If

'Convert and show the time
time = SecToTime(ClockGetDif)
If mode = Client Then zmudcommand 175, array(VBCrLf & "According to your watch it's " & time & ".")
If mode = Say Then zmudcommand 178, array("emote quickly glances down and says 'It's " & time & ".'")
If mode = Tell Then zmudcommand 178, array("tell " & player & " The current time is " & time & ".")
If mode = Narrate Then zmudcommand 178, array("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
_________________
Taz :)
Reply with quote
hoot
Newbie


Joined: 30 Apr 2004
Posts: 6
Location: USA

PostPosted: Tue May 30, 2006 7:20 am   
 
Works great thanks :)
_________________
It's not the years, hony, it's the mileage.
Reply with quote
Somnium
Beginner


Joined: 15 Nov 2008
Posts: 10

PostPosted: Thu Jan 24, 2013 8:59 pm   
 
Can't get this script to work in cmud for some reason.
I get an "error parsing command" (source not available for runtime errors)

ideas?
/C
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net