This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

colourful output

Old posts that have not been replied to for several years.
Locked
f
fajja
Voice
Posts: 14
Joined: Sun May 08, 2005 7:48 am

colourful output

Post by fajja »

Hi, i got this script working , its from the warmanager.tcl. however i want to brighten things up a bit. I have it so that it says most of the stuff and white writing on a blue background. but if the information its displaying is from a stored variable (such as a n upcoming match then these lines are plain black and white. here is part of the code
proc war_upcoming {nick uhost handle channel arg} {
global war_list war_privchan war_shownumber war_nicksize war_trigger
set channel [string tolower $channel]
if {[llength $arg]==0} {
set arg $war_shownumber
} elseif {([llength $arg]>1)||($arg>10)} {
putserv "NOTICE $nick :\002\0030,2Invalid args ( [string trim $war_trigger]upcoming <number> ) and <number have to be 10 or lower."
return 0
}
if {$channel==$war_privchan} {
set war_upcoming
  • foreach war $war_list {
    if {([lrange $war 3 4]=="n/a n/a")&&([lindex $war 1]>[unixtime])} {
    set war_upcoming [linsert $war_upcoming end [lindex $war 0]]
    }
    }
    if {[llength $war_upcoming]>0} {
    putserv "PRIVMSG $channel : \002\0030,2Upcoming Matches :"
    set warid ""
    for {set x 0} {$x<$arg} {incr x} {
    if {$x>[expr [llength $war_upcoming]-1]} {
    break
    }
    set warid [linsert $warid end [lindex $war_upcoming $x]]
    }
    set infos ""
    for {set x 0} {$x<[llength $warid]} {incr x} {
    set tempinfos [war_getinfos [lindex $warid $x] $war_nicksize]
    set hour [lindex $tempinfos 1]
    set date [lindex $tempinfos 2]
    set players [lindex $tempinfos 7]
    set number [lindex $tempinfos 9]
    set actualplayers [lindex $tempinfos 10]
    set tempinfos [lreplace $tempinfos 9 10]
    set tempinfos [lreplace $tempinfos 4 5]
    if {[string first "- Substitute:" $players]>-1} {
    set stringindex [string first "- Substitute:" $players]
    set players "[string range $players 0 [expr $stringindex-1]][string range $players [expr $stringindex+1] [expr $stringindex+13]][string range $players [expr $stringindex+15] end]"
    set tempinfos [lreplace $tempinfos 5 5 $players]
    }
    set tempinfos [lreplace $tempinfos 5 5 "[lindex $tempinfos 5] ($actualplayers/$number)"]
    set tempinfos [lreplace $tempinfos 1 2 "$date - $hour"]
    set tempinfos [linsert $tempinfos 1 [lindex $tempinfos 2]]
    set tempinfos [lreplace $tempinfos 3 3]
    set infos [linsert $infos end $tempinfos]
    }
    set infos [linsert $infos 0 "ID: Opponent: Date: Maps: Players: Infos:"]
    for {set x 0} {$x<6} {incr x} {
    set length 0
    for {set y 0} {$y<[llength $infos]} {incr y} {
    if {[string length [lindex [lindex $infos $y] $x]]>$length} {
    set length [string length [lindex [lindex $infos $y] $x]]
    }
    }
    incr length 3
    for {set y 0} {$y<[llength $infos]} {incr y} {
    for {set z [string length [lindex [lindex $infos $y] $x]]} {$z<$length} {incr z} {
    set newelement "[lindex [lindex $infos $y] $x] "
    set newinfos [lreplace [lindex $infos $y] $x $x $newelement]
    set infos [lreplace $infos $y $y $newinfos]
    }
    }
    }
    set length 0
    for {set y 1} {$y<[llength $infos]} {incr y} {
    if {[string length [lindex [lindex [lindex $infos $y] 2] 0]]>$length} {
    set length [string length [lindex [lindex [lindex $infos $y] 2] 0]]
    }
    }
    incr length
    for {set y 1} {$y<[llength $infos]} {incr y} {
    for {set z [string length [lindex [lindex [lindex $infos $y] 2] 0]]} {$z<$length} {incr z} {
    set newelement "[lindex [lindex [lindex $infos $y] 2] 0] "
    set newdate [lreplace [lindex [lindex $infos $y] 2] 0 0 $newelement]
    set newdate [string range $newdate 0 [expr [string length $newdate]-2]]
    set newinfos [lreplace [lindex $infos $y] 2 2 $newdate]
    set infos [lreplace $infos $y $y $newinfos]
    }
    set newdate "[lindex [lindex $infos $y] 2] "
    set newinfos [lreplace [lindex $infos $y] 2 2 [join $newdate]]
    set infos [lreplace $infos $y $y $newinfos]
    }
    for {set x 0} {$x<6} {incr x} {
    set newelement "\002\0030,2[lindex [lindex $infos 0] $x]"
    set newinfos [lreplace [lindex $infos 0] $x $x $newelement]
    set infos [lreplace $infos 0 0 $newinfos]
    }
    for {set x 0} {$x<[llength $infos]} {incr x} {
    set infos [lreplace $infos $x $x [join [lindex $infos $x]]]
    }
    for {set x 0} {$x<[llength $infos]} {incr x} {
    putserv "PRIVMSG $channel :[lindex $infos $x]"
    }
    if {$arg>[llength $warid]} {
    putserv "PRIVMSG $channel :\002\0030,2You have seen all match"
    return 0
    }
    } else {
    putserv "NOTICE $nick :\002\0030,2No match found"
    return 0
    }
    }
    }
\002\0030,2 is the colours i want to use but i dont know where to put the code that the the output from match variable will be the same colours...
thank you for any help!
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

you can add "\002\0030,2" before the variable. Something like:

Code: Select all

putserv "PRIVMSG $channel :\002\0030,2$arg"
f
fajja
Voice
Posts: 14
Joined: Sun May 08, 2005 7:48 am

Post by fajja »

ok i tried that, i get more part with colour in it now, but it still doesnt affect the output for the tabled variable, if an argument is in [ ] do i have to put the colour code in the brackets or outside?
for {set x 0} {$x<[llength $infos]} {incr x} {
putserv "PRIVMSG $channel :[lindex $infos $x]"
}
i tried
for {set x 0} {$x<[llength $infos]} {incr x} {
putserv "PRIVMSG $channel :[\colourbitinheere lindex $infos $x]"
}
but this blocked the output :(
cheers for your help!
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

it should be:

Code: Select all

putserv "PRIVMSG $channel :\colourbitinheere[lindex $infos $x]"
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

For detailed information on TCL colour codes see this post by ppslim.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
f
fajja
Voice
Posts: 14
Joined: Sun May 08, 2005 7:48 am

Post by fajja »

i tried what sir_fz said, but it still wont output the colours.. it works for simple things. but when i try and get it to output variable in a msg, they are still in black and white no matter where i put the code :(

any suggestions?
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Hmm.. try:

Code: Select all

putserv "PRIVMSG $channel :[lindex \0034$infos\017 \035$x]"
\017 resets to the default output.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Locked