Toolbar Digital Clock
Platform: mIRC
Published Dec 27, 2011
Updated Jan 06, 2012
Firstly I'd like to give a shout out to xdesoto since his clock script gave me the idea to do this.
Secondly this script is completely different than his in all but the fact they are both digital styled clocks.
This clock appears in the toolbar and has 12/24 hour modes which can easily be toggled by clicking on the clock. To start type /clock or /clock 12 to start in 12 hour mode. The clock will start with mirc if you leave it on before closing mirc.
This script doesn't use pictures for the display unlike xdesoto's and my older one I posted in the comments of his snippet. This draws all of the characters from scratch using an alias that was simpler than I thought it'd be, lol.
Type /clockcolors to bring up the color picker. You can either type in numbers into the rgb edit boxes or use the slider. The clock will update in near real time, you'll have to wait up to a second lol. Non valid entries in the rgb edit boxes will be replaced with 0, including if you try to delete all the numbers, if you wish to change the whole number just select it and edit it.
There is an option to display the color selections in the color dialog selector. This is turned off by default since it's quite CPU intensive as it has to created picture files and load them every time the value changes.
Right clicking on the clock also shows the option to switch between 12/24 hours times and to open the color dialog.
Guess what? Yet another update.
Just trying to condense the script a bit, removed a lot of duplicate code and I'll be doing more when I can.
1-5-12
whoops used an online timer so any time you get disconnected the clock stops until you restart/toggle it, switched to offline timer which fixes that
1-6-12
updated it to sync itself with the computer time. since the timer runs every second from the time it's started which means it's up to just under a second off the computers time. Now every minute it syncs itself to the computers time.
/*
[Addon]
Script=Toolbar Clock
Version=2.7
Author=pball
Desc=Shows a digital clock in the toolbar
For=Mirc
Date=
[script]
*/
alias clock {
set %startclock clock $1
if (!$isfile($scriptdirclock.txt)) popupfile
if (!%clockcolors) set %clockcolors 0 255 0 11 74 19 0 0 0 0
if (!$toolbar(clocksep)) toolbar -is clocksep
if (!$window(@clock)) window -nBj2kpw0 +f @clock 0 0 117 23
if (!$toolbar(clock)) toolbar -auxo clock "" @clock 0 0 $iif($1 == 12,111,82) 17
clear @clock
set -l %time $asctime($iif($1 == 12,hhcnncsstt,HHcnncss))
set -l %num 1
while ($mid(%time,%num,1) != $null) {
if ($mid(%time,1,1) != 0) || (%num != 1) || ($1 != 12) numbers $mid(%time,%num,1) $gettok(0 12 24 29 41 53 58 70 $iif($1 == 12,87 99),%num,32)
else numbers null 0
inc %num
}
toolbar -pu clock @clock 0 0 $iif($1 == 12,111,82) 17
toolbar -l clock "/clockchange"
toolbar -o clock $scriptdirclock.txt
.timerclock -mo $iif($asctime(ss) == 00,$asctime(HH:nn) 1 0,1 1000) clock $iif($1 == 12,$v1)
}
on *:start: if (%startclock) { .timerclock -o 1 1 %startclock | unset %startclock }
alias clockchange { clock $iif($timer(clock).com == clock 12,,12) }
alias clockoff {
unset %startclock
.timerclock off
toolbar -d clocksep
toolbar -d clock
window -c @clock
}
alias -l popupfile {
write -c $scriptdirclock.txt Switch to $($iif($timer(clock).com == clock 12,24,12),0) Hour Time: clock $($iif($timer(clock).com == clock 12,,12),0)
write $scriptdirclock.txt $(Change Colors: if (!$dialog(clockcolors)) dialog -ma clockcolors clockcolors,0)
}
alias -l numbers {
if ($2 == 0) drawdot -r @clock $rgb( [ $replace($gettok(%clockcolors,7-9,32),$chr(32),$chr(44)) ] ) 75 50 10
if ($1 == c) {
set -l %num 1
while (%num <= 4) {
drawline -r @clock $c2 1 $calc($2 + $gettok(1 5 11 13,%num,32)) $gettok(3 5 11 13,%num,32) $calc($2 + 4) $gettok(3 5 11 13,%num,32)
inc %num
}
drawline -r @clock $c1 3 $calc($2 + 2) 4 $calc($2 + 2) 4
drawline -r @clock $c1 3 $calc($2 + 2) 12 $calc($2 + 2) 12
return
}
drawline -r @clock $iif($1 isin ap02356789,$c1,$c2) 1 $calc($2 + 2) 1 $calc($2 + 10) 1
drawline -r @clock $iif($1 isin ap02356789,$c1,$c2) 1 $calc($2 + 3) 2 $calc($2 + 9) 2
drawline -r @clock $iif($1 isin apm045689,$c1,$c2) 1 $calc($2 + 1) 2 $calc($2 + 1) 7
drawline -r @clock $iif($1 isin apm045689,$c1,$c2) 1 $calc($2 + 2) 3 $calc($2 + 2) 8
drawline -r @clock $iif($1 isin apm0268,$c1,$c2) 1 $calc($2 + 1) 10 $calc($2 + 1) 15
drawline -r @clock $iif($1 isin apm0268,$c1,$c2) 1 $calc($2 + 2) 9 $calc($2 + 2) 14
drawline -r @clock $iif($1 isin 023568,$c1,$c2) 1 $calc($2 + 2) 15 $calc($2 + 10) 15
drawline -r @clock $iif($1 isin 023568,$c1,$c2) 1 $calc($2 + 3) 14 $calc($2 + 9) 14
drawline -r @clock $iif($1 isin apm01234789,$c1,$c2) 1 $calc($2 + 10) 2 $calc($2 + 10) 7
drawline -r @clock $iif($1 isin apm01234789,$c1,$c2) 1 $calc($2 + 9) 3 $calc($2 + 9) 8
drawline -r @clock $iif($1 isin am013456789,$c1,$c2) 1 $calc($2 + 10) 10 $calc($2 + 10) 15
drawline -r @clock $iif($1 isin am013456789,$c1,$c2) 1 $calc($2 + 9) 9 $calc($2 + 9) 14
drawline -r @clock $iif($1 isin ap2345689,$c1,$c2) 3 $calc($2 + 4) 8 $calc($2 + 7) 8
if ($1 == m) {
set -l %num 1
while (%num <= 6) {
drawline -r @clock $c1 1 $calc($2 + $gettok(2 3 4 5 7 8,%num,32)) $gettok(1 2 3 4 2 1,%num,32) $calc($2 + $gettok(4 5 8 7 9 10,%num,32)) $gettok(1 2 3 4 2 1,%num,32)
inc %num
}
}
}
alias c1 { return $rgb( [ $replace($gettok(%clockcolors,1-3,32),$chr(32),$chr(44)) ] ) }
alias c2 { return $rgb( [ $replace($gettok(%clockcolors,4-6,32),$chr(32),$chr(44)) ] ) }
dialog clockcolors {
title "Clock Colors"
size -1 -1 400 230
option pixels
text "Main", 3, 5 5 55 17
icon 105, 5 25 40 40
text "Red", 5, 70 5 34 17
text "Green", 6, 70 25 34 17
text "Blue", 7, 70 45 34 17
edit "", 100, 105 5 35 20, limit 3
edit "", 200, 105 25 35 20, limit 3
edit "", 300, 105 45 35 20, limit 3
scroll "", 101, 140 5 256 16, horizontal range 1 256
scroll "", 201, 140 25 256 16, horizontal range 1 256
scroll "", 301, 140 45 256 16, horizontal range 1 256
text "Secondary", 12, 5 75 55 17
icon 405, 5 95 40 40
text "Red", 14, 70 75 34 17
text "Green", 15, 70 95 34 17
text "Blue", 16, 70 115 34 17
edit "", 400, 105 75 35 20, limit 3
edit "", 500, 105 95 35 20, limit 3
edit "", 600, 105 115 35 20, limit 3
scroll "", 401, 140 75 256 16, horizontal range 1 256
scroll "", 501, 140 95 256 16, horizontal range 1 256
scroll "", 601, 140 115 256 16, horizontal range 1 256
text "Background", 23, 5 140 55 17
icon 705, 5 160 40 40
text "Red", 25, 70 140 34 17
text "Green", 26, 70 160 34 17
text "Blue", 27, 70 180 34 17
edit "", 700, 105 140 35 20, limit 3
edit "", 800, 105 160 35 20, limit 3
edit "", 900, 105 180 35 20, limit 3
scroll "", 701, 140 140 256 16, horizontal range 1 256
scroll "", 801, 140 160 256 16, horizontal range 1 256
scroll "", 901, 140 180 256 16, horizontal range 1 256
check "Check for color samples to update (Warning CPU intensive)", 1, 5 205 360 17
}
alias clockcolors { if (!$dialog(clockcolors)) dialog -ma clockcolors clockcolors }
on *:dialog:clockcolors:*:*: {
if ($devent == close) {
set %clockcolors $did(100) $did(200) $did(300) $did(400) $did(500) $did(600) $did(700) $did(800) $did(900) $did(1).state
.remove $scriptdirclock1.bmp
.remove $scriptdirclock2.bmp
.remove $scriptdirclock3.bmp
}
elseif ($devent == init) {
if (!%clockcolors) set %clockcolors 0 255 0 11 74 19 0 0 0 0
set -l %num 1
while (%num <= 9) {
did -a $dname %num $+ 00 $gettok(%clockcolors,%num,32)
did -c $dname %num $+ 01 $gettok(%clockcolors,%num,32)
inc %num
}
if ($gettok(%clockcolors,10,32)) did -c $dname 1
refreshcolors
}
elseif ($devent == scroll) {
did -ra $dname $calc($did - 1) $calc($did($did).sel - 1)
refreshcolors
}
elseif ($devent == edit) {
if ($did($did) isnum 0-255) did -c $dname $calc($did + 1) $did($did)
else did -ra $dname $did 0
refreshcolors
}
elseif ($devent == sclick) {
if ($did == 1) { did - $+ $iif($did(1).state,v,h) $dname 105,405,705 | if ($did(1).state == 1) refreshcolors }
}
}
alias -l refreshcolors { set %clockcolors $did(100) $did(200) $did(300) $did(400) $did(500) $did(600) $did(700) $did(800) $did(900) | if ($did(1).state == 1) clockcolor }
alias -l clockcolor {
set -l %num 1
while (%num <= 3) {
window -nBfj2kpw0 +f @color $+ %num 0 0 40 40
drawdot -r @color $+ %num $rgb($gettok(%clockcolors,$calc(1 + (( %num -1)*3) ),32),$gettok(%clockcolors,$calc(2 + (( %num -1)*3) ),32),$gettok(%clockcolors,$calc(3 + (( %num -1)*3) ),32)) 120 20 20
drawsave @color $+ %num $scriptdirclock $+ %num $+ .bmp
window -c @color $+ %num
did -g clockcolors $calc(1 + (( %num -1)*3) ) $+ 05 $scriptdirclock $+ %num $+ .bmp
inc %num
}
}