|
Joined: Aug 2004
Posts: 423
Fjord artisan
|
OP
Fjord artisan
Joined: Aug 2004
Posts: 423 |
hello again, i'm trying to write a lil script that sets the title with various info selected from a dialog... i have a few things figured out and working so far.. but two things i'm having trouble figuring out : 1. how to get the time to appear.. when i use the alias on it's own it seems to work fine.. but in the script i get the old not connected error... but i can't figure it out.. 2. i can't seem to get the nick modes to update on it's own : example... if i set mode +x it doesn't update it on the titlebar unless i click the apply button.. and on disconnect i would need it to reset (clear the titlebar to options that would be seen when disconnected) i hope i'm making sense here here is my code as is, so far: dialog tb_test {
title "Titlebar Test"
size -1 -1 174 55
option dbu
box "Options", 1, 3 3 162 50
check "Online Status", 2, 9 12 43 10
check "Nick +modes", 3, 9 23 43 10
check "Script Name", 4, 9 33 42 10
check "Nick Scroll", 5, 57 22 50 10
check "Server", 6, 110 12 50 10
check "Current Time", 7, 110 23 50 10
check "Away Status", 8, 110 33 50 10
button "OK", 9, 56 40 19 10, ok
button "Apply", 10, 86 40 19 10
}
alias amsw { writeini -n $+(",$mircdirdat\ini\,$1,") $2 $3 $$4- }
alias amsr return $readini($+(",$mircdirdat\ini\,$1,"),n,$2,$$3)
alias set.tb { /titlebar $tb.logo $tb.status $tb.server $tb.umodes $tb.time }
alias tb.logo { if ($amsr(TitleBar.ini,TitleBar,Script) = On) { return - $amlogo } | else { return } }
alias tb.time { if ($amsr(TitleBar.ini,TitleBar,CTime) == On) { return - $cttimer } | elseif ($amsr(TitleBar.ini,TitleBar,CTime) == Off) { timercurrentt off } | else { return } }
alias tb.status { if ($amsr(TitleBar.ini,TitleBar,Online) == On) { return Status: $status } | else { return } }
alias tb.server { if ($server != $null) && ($amsr(TitleBar.ini,TitleBar,Server) == On) { return Server: $server } | else { return } }
alias tb.umodes { if (($scid($activecid).server != $null) && ($amsr(TitleBar.ini,TitleBar,Modes) == On)) { return - $scid($activecid).me $iif($scid($activecid).usermode != +,$scid($activecid).usermode) } }
alias amlogo { return -= (A)(M)(S)V1.5 =- }
alias cttimer { .timercurrentt -o 0 1 $ctime }
alias ctime { $time(ddd $+ $chr(32) $+ mmm $+ $chr(44) dd $+ $chr(32) h:nntt) }
on *:dialog:tb_test:*:*:{
if ($devent == init) {
if ($amsr(Titlebar.ini,TitleBar,Online) == On) { did -c $dname 2 }
if ($amsr(TitleBar.ini,TitleBar,Modes) == On) { did -c $dname 3 }
if ($amsr(TitleBar.ini,TitleBar,Script) == On) { did -c $dname 4 }
if ($amsr(TitleBar.ini,TitleBar,NScroll) == On) { did -c $dname 5 }
if ($amsr(Titlebar.ini,TitleBar,Server) == On) { did -c $dname 6 }
if ($amsr(TitleBar.ini,TitleBar,CTime) == On) { did -c $dname 7 }
if ($amsr(TitleBar.ini,TitleBar,Away) == On) { did -c $dname 8 }
}
if ($devent == sclick) {
if ($did == 2) { /amsw TitleBar.ini TitleBar Online $iif($did(2).state,On,Off) }
if ($did == 3) { /amsw TitleBar.ini TitleBar Modes $iif($did(3).state,On,Off) }
if ($did == 4) { /amsw TitleBar.ini TitleBar Script $iif($did(4).state,On,Off) }
if ($did == 5) { /amsw TitleBar.ini TitleBar NScroll $iif($did(5).state,On,Off) }
if ($did == 6) { /amsw TitleBar.ini TitleBar Server $iif($did(6).state,On,Off) }
if ($did == 7) { /amsw TitleBar.ini TitleBar CTime $iif($did(7).state,On,Off) }
if ($did == 8) { /amsw TitleBar.ini TitleBar Away $iif($did(8).state,On,Off) }
if ($did == 10) { $set.tb }
}
}
on *:connect:{ $set.tb }
on *:disconnect:{ $set.tb }
menu menubar {
TitleBar:/dialog -m tb_test tb_test
}
i hope someone can help with this as always i'm openned to suggestions on how i could improve this script if anyone wishes to give some pointers/hints/ect..... on any other parts of the code thanks in advance!
|
|
|
|
Joined: Dec 2002
Posts: 1,922
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,922 |
Here is a small script that should help you solve the time & usermode update issues: ; Calls /tb_update every minute to update the time displayOn *:start: .timerTB_UPDATE 0 60 tb_update; Calls /tb_update on every user-mode changeOn *:usermode: tb_update
alias tb_update {- var %time = $time(ddd mmm $+ $chr(44) dd h:nntt)
var %mode = $usermode titlebar %time $+([, %mode, ]) }If you're going to make the timer update the titlebar every second then I recommend that you store your settings either in variables or a hash table, because writing to and reading from (INI) files is relatively slow and wears your hard disk. Also, note that your $ctime alias never gets called, because it's overridden by mIRC's inbuilt $ctime. It's a good practice to give your aliases unique names that do not conflict with mIRC's commands or identifiers.
|
|
|
|
Joined: Aug 2004
Posts: 423
Fjord artisan
|
OP
Fjord artisan
Joined: Aug 2004
Posts: 423 |
thanks Online for pointing out the alias error. i totaly had a brian fart on that, don't know know why it didn't dawn on me about mircs $ctime.. and in reply to.... If you're going to make the timer update the titlebar every second then I recommend that you store your settings either in variables or a hash table, because writing to and reading from (INI) files is relatively slow and wears your hard disk. i'm not famillar with hash tables, so i guess i'll try your advice on the %vars.... but, i have a question....... looking at your example script, would i have to set all my options to variables? because the whole thing isn't updated with a timer just the time and the umodes would be controlled by a timmer i guess.. does that make the whole titlebar update every sec as well?
|
|
|
|
Joined: Dec 2002
Posts: 1,922
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,922 |
It would be easier to store all settings in variables. After all, there aren't many. But if the user chooses to disable the display of time in the titlebar then there's no point in updating it every second with a timer. This script will turn on the timer only when %tb_showtime is enabled. It will also enable the "on usermode" event only when the user-mode is supposed to be displayed. For more info on the #tb_umode_update item, type /help groups When you feel that the script is working properly, you can remove the debugging /echo commands. [color:blue]; | Dialog
; |________
; Configuration dialog goes here.
;
; The following variables should be either 1 (enabled) or 0 (disabled):
;
; [color:darkorange]%tb_enabled[/color] (controls the whole script)
;
; [color:darkorange]%tb_showlogo %tb_showstatus[/color]
; [color:darkorange]%tb_showserver %tb_showtime[/color]
; [color:darkorange]%tb_showumode[/color]
;
; Tip: to delete all variables at once, use /unset %tb_*
;
; Tip: call /tb_reset when the Apply button is clicked.
; | Events
; |________[/color]
[color:green]On *:start: tb_reset
[color:brown]#tb_umode_update[/color] off
On *:usermode: tb_update
[color:brown]#tb_umode_update[/color] end[/color]
[color:blue]; | Aliases
; |_________[/color]
[color:green]alias tb_reset {
echo -cae info *** Resetting titlebar settings
if ![color:darkorange]%tb_enabled[/color] {
.timerTB_UPDATE off
.disable [color:brown]#tb_umode_update[/color]
return
}
tb_update
if [color:darkorange]%tb_showtime[/color] { .timerTB_UPDATE 0 1 tb_update }
else .timerTB_UPDATE off
if [color:darkorange]%tb_showumode[/color] { .enable [color:brown]#tb_umode_update[/color] }
else .disable [color:brown]#tb_umode_update[/color]
}
alias tb_update {
echo -cae info *** Updating titlebar
titlebar $_logo $_status $_server $_time $_mode
}
alias -l _logo { if [color:darkorange]%tb_showlogo[/color] { return -= (A)(M)(S)V1.5 =- } }
alias -l _status { if [color:darkorange]%tb_showstatus[/color] { return $status } }
alias -l _server { if [color:darkorange]%tb_showserver[/color] { return $server } }
alias -l _time {
if [color:darkorange]%tb_showtime[/color] { return $time(ddd mmm $+ $chr(44) dd h:nn:ss tt) }
}
alias -l _umode { if [color:darkorange]%tb_showumode[/color] { return $usermode } }[/color]
[color:blue]; | End[/color]
|
|
|
|
Joined: Aug 2004
Posts: 423
Fjord artisan
|
OP
Fjord artisan
Joined: Aug 2004
Posts: 423 |
ok i strongly feel that i'm missing something here! this is what i have now : menu menubar {
TitleBar:/dialog -m tb_test tb_test
}
dialog tb_test {
title "Titlebar Test"
size -1 -1 174 55
option dbu
box "Options", 1, 3 3 162 50
check "Online Status", 2, 9 12 43 10
check "Nick +modes", 3, 9 23 43 10
check "Script Name", 4, 9 33 42 10
check "Nick Scroll", 5, 57 22 50 10
check "Server", 6, 110 12 50 10
check "Current Time", 7, 110 23 50 10
check "Away Status", 8, 110 33 50 10
button "OK", 9, 56 40 19 10, ok
button "Apply", 10, 86 40 19 10
}
on *:dialog:tb_test:*:*:{
if ($devent == init) {
if ($amsr(Titlebar.ini,TitleBar,Online) == On) { did -c $dname 2 }
if ($amsr(TitleBar.ini,TitleBar,Modes) == On) { did -c $dname 3 }
if ($amsr(TitleBar.ini,TitleBar,Script) == On) { did -c $dname 4 }
if ($amsr(TitleBar.ini,TitleBar,NScroll) == On) { did -c $dname 5 }
if ($amsr(Titlebar.ini,TitleBar,Server) == On) { did -c $dname 6 }
if ($amsr(TitleBar.ini,TitleBar,CTime) == On) { did -c $dname 7 }
if ($amsr(TitleBar.ini,TitleBar,Away) == On) { did -c $dname 8 }
}
if ($devent == sclick) {
if ($did == 2) { /amsw TitleBar.ini TitleBar Online $iif($did(2).state,On,Off) }
if ($did($dname,2).state == 1) { /set %tb_showstatus }
if ($did == 3) { /amsw TitleBar.ini TitleBar Modes $iif($did(3).state,On,Off) }
if ($did($dname,3).state == 1) { /set %tb_showumode }
if ($did == 4) { /amsw TitleBar.ini TitleBar Script $iif($did(4).state,On,Off) }
if ($did($dname,4).state == 1) { /set %tb_showlogo }
if ($did == 5) { /amsw TitleBar.ini TitleBar NScroll $iif($did(5).state,On,Off) }
if ($did == 6) { /amsw TitleBar.ini TitleBar Server $iif($did(6).state,On,Off) }
if ($did($dname,6).state == 1) { /set %tb_showserver }
if ($did == 7) { /amsw TitleBar.ini TitleBar CTime $iif($did(7).state,On,Off) }
if ($did($dname,7).state == 1) { /set %tb_showtime && /set %tb_enabled }
if ($did == 8) { /amsw TitleBar.ini TitleBar Away $iif($did(8).state,On,Off) }
if ($did == 10) { /tb_reset }
}
}
On *:start: tb_reset
On *:exit: /unset %tb_*
#tb_umode_update off
On *:usermode: tb_update
#tb_umode_update end
alias amsw { writeini -n $+(",$mircdirdat\ini\,$1,") $2 $3 $$4- }
alias amsr return $readini($+(",$mircdirdat\ini\,$1,"),n,$2,$$3)
alias tb_reset {
echo -cae info *** Resetting titlebar settings
if !%tb_enabled {
.timerTB_UPDATE off
.disable #tb_umode_update
return
}
tb_update
if %tb_showtime { .timerTB_UPDATE 0 1 tb_update }
else .timerTB_UPDATE off
if %tb_showumode { .enable #tb_umode_update }
else .disable #tb_umode_update
}
alias tb_update {
echo -cae info *** Updating titlebar
titlebar $_logo $_status $_server $_time $_umode
}
alias -l _logo { if %tb_showlogo { return -= (A)(M)(S)V1.5 =- } }
alias -l _status { if %tb_showstatus { return $status } }
alias -l _server { if %tb_showserver { return $server } }
alias -l _time {
if %tb_showtime { return $time(ddd mmm $+ $chr(44) dd h:nn:ss tt) }
}
alias -l _umode { if %tb_showumode { return $usermode } }
i'm pretty sure i follow about the variables being set to 1 an 0, but the %tb_enabled thing is throwing me some..... i am failing to see how to have it initiate.... i understand how it works but, stairing at it i just can't figure out how to make it work.. lol (at myself) ...... (am starting to feel like a baby needing to hold someones hand with this.. ) anyways, perhaps a lil more info on it.. might help?? thanks in advance(again)
|
|
|
|
Joined: Apr 2003
Posts: 342
Fjord artisan
|
Fjord artisan
Joined: Apr 2003
Posts: 342 |
Use $true/$false instead of 'on'. Take a look at this...
ON *:SIGNAL:TITLEBAR.UPDATE: {
var %showcon = $readconfig(titlebar.display,show.connection,$true)
var %shownetwork = $readconfig(titlebar.display,show.network,$true)
var %showaway = $readconfig(titlebar.display,show.away,4)
var %showservices = $readconfig(titlebar.display,show.services,$true)
var %showchanstats = $readconfig(titlebar.display,show.chanstats,$false)
var %showidle = $readconfig(titlebar.display,show.idle,4)
var %idletreshhold = $readconfig(titlebar.display,show.idle.treshhold,600)
if (%showcon) { %p.tb = %p.tb $+([,$activecon,\,$scon(0),]) - }
if ($status == Connected) {
if ($away) && (%showaway) {
if ((%showaway == 5) || ($mouse.key & 2)) {
%p.tb = %p.tb [AWAY: $+ $shortduration($awaytime,0) $+ ]]
}
elseif (%showaway == 4) {
if ($awaytime < 3600) { %p.tb = %p.tb [AWAY: $+ $deltok($shortduration($awaytime,0),1,32) $+ ]] }
else { %p.tb = %p.tb [AWAY: $+ $shortduration($awaytime,1) $+ ]] }
}
elseif (%showaway == 3) {
if ($awaytime < 3600) { %p.tb = %p.tb [AWAY: $+ $deltok($shortduration($awaytime,0),1,32) $+ ]] }
else { %p.tb = %p.tb [AWAY: $+ $shortduration($awaytime,0) $+ ]] }
}
elseif (%showaway == 2) {
%p.tb = %p.tb [AWAY: $+ $shortduration($awaytime,1) $+ ]]
}
else {
%p.tb = %p.tb = [AWAY]
} }
elseif (%shownetwork) {
if ($scid($activecid).network) { %p.tb = %p.tb [[ $+ $ifmatch $+ ]] }
else { %p.tb = %p.tb [[ $+ $status $+ ]] }
} }
elseif (%shownetwork) { %p.tb = %p.tb [OFFLINE] }
if (($status == Connected) && ($scid($activecid).network == DALNET) && ($services == OFFLINE) && %showservices) {
%p.tb = %p.tb - [**SERVICES OFFLINE**]
}
if ($active ischan) && (%showchanstats) {
var %opers = $isoper($active), %aways = $isaway($active)
%p.tb = %p.tb - [[ $+ $upper($active) - / $+ V: $+ $base($nick($active,0,v),10,10,2) $+ / $+ @: $+ $base($nick($active,0,o),10,10,2) $+ $&
/ $+ E $+ $iif(%opers < 10,0) $+ %opers $+ / $+ Ã: $+ $iif(%aways < 10,0) $+ %aways $+ ]]
if ($ial && ($chan($active).IAL == $false)) {
var %ial = $calc($ialchan(*,$active,0) / $nick($active,0) * 100)
if ((%ial > 99) && (%ial < 99.9)) { %ial = 99 }
%p.tb = %p.tb - [IAL: $+ $round(%ial,0) $+ % $+ ]
} }
if (($idle > %idletreshhold) && %showidle) {
if ((%showidle == 5) || ($mouse.key & 2)) {
%p.tb = %p.tb - [IDLE: $+ $shortduration($idle,0) $+ ]]
}
elseif (%showidle == 4) {
if ($idle < 3600) { %p.tb = %p.tb - [IDLE: $+ $deltok($shortduration($idle,0),1,32) $+ ]] }
else { %p.tb = %p.tb - [IDLE: $+ $shortduration($idle,1) $+ ]] }
}
elseif (%showidle == 3) {
if ($idle < 3600) { %p.tb = %p.tb - [IDLE: $+ $deltok($shortduration($idle,0),1,32) $+ ]] }
else { %p.tb = %p.tb - [IDLE: $+ $shortduration($idle,0) $+ ]] }
}
elseif (%showidle == 2) {
%p.tb = %p.tb - [IDLE: $+ $shortduration($idle,1) $+ ]]
}
else {
%p.tb = %p.tb - [IDLE]
} }
if ($mouse.key & 2) {
if ($mouse.key & 4) { %p.tb = %p.tb - $+([,SYSTEM:,$SHORTDURATION($UPTIME(SYSTEM,3)),]) }
elseif ($status == Connected) { %p.tb = %p.tb - $+([,SERVER:,$SHORTDURATION($UPTIME(SERVER,3),0),]) }
%p.tb = %p.tb - $file(XML.TXT).size
}
;-- Creates Weekly array table
if !$hget(FFXI.VanaDay) {
hmake FFXI.VanaDay 9
hadd FFXI.VanaDay n0 Fire
hadd FFXI.VanaDay n1 Earth
hadd FFXI.VanaDay n2 Water
hadd FFXI.VanaDay n3 Wind
hadd FFXI.VanaDay n4 Ice
hadd FFXI.VanaDay n5 Thunder
hadd FFXI.VanaDay n6 Light
hadd FFXI.VanaDay n7 Darkness
hadd FFXI.VanaDay n8 Fire
}
; -- Get's curent and vlocal time
var %vlocaltime = $calc((898 * 360 + 30) * 24 * 60 * 60 * 1000 / 25)
var %Bday = $calc($ctime(23/06/2002 8:00:04) * 1000)
var %diff = $calc(%vlocaltime - %Bday)
var %eTime = $calc($ctime * 1000)
; -- difference between earth time a Vanatime
var %vTime = $calc((%eTime + %Diff) * 25)
; -- calculates the year/month/day etc
var %vYear = $base($floor($calc(%vTime / (360 * 24 * 60 * 60 * 1000))),10,10,4)
var %vMon = $base($floor($calc((%vTime % (360 * 24 * 60 * 60 * 1000)) / (30 * 24 * 60 * 60 * 1000) + 1)),10,10,2)
var %vDate = $base($floor($calc((%vTime % (30 * 24 * 60 * 60 * 1000)) / (24 * 60 * 60 * 1000) + 1)),10,10,2)
var %vHour = $base($floor($calc((%vTime % (24 * 60 * 60 * 1000)) / (60 * 60 * 1000))),10,10,2)
var %vMin = $base($floor($calc((%vTime % (60 * 60 * 1000)) / (60 * 1000))),10,10,2)
var %vSec = $base($floor($calc((%vTime % (60 * 1000)) / 1000)),10,10,2)
var %vDay = $floor($calc((%vTime % (8 * 24 * 60 * 60 * 1000)) / (24 * 60 * 60 * 1000)))
; -- output text
var %VanaTxt = $+(%vYear,/,%vMon,/,%vDate,$chr(40),$hget(FFXI.VanaDay,$+(n,%vDay)),$chr(41)) $+(%vHour,:,%vMin)
;-- %VanaTxt = %VanaTxt $+ : $+ %vSecaqf
;-- appends output variable
IF (%p.last.year.date == $null) { %p.last.year.date = %vTime %vYear }
if (%p.last.year.date != %vYear) {
%p.last.year.date = %vYear
splay $quote($+($wavedir,error.wav))
}
%p.tb = %p.tb - $+([,%VanaTxt,])%vNextDay
}
Beware of MeStinkBAD! He knows more than he actually does!
|
|
|
|
Joined: Aug 2004
Posts: 423
Fjord artisan
|
OP
Fjord artisan
Joined: Aug 2004
Posts: 423 |
i appreciate the response MeStinkBAD, but what am i supposed to be looking at?? most of that code is like greek to me........ thanks anyways
|
|
|
|
|