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.

Store colored text.

Help for those learning Tcl or writing their own scripts.
Post Reply
o
oxygen
Voice
Posts: 22
Joined: Mon Sep 05, 2005 2:22 pm
Location: Germany

Store colored text.

Post by oxygen »

Hi,

hope somebody can help...

I want to store a colored text in a variable. And only the words in this specific color. I don't even know if it's possible...
Example:
This text is only an example for what I need.

Code: Select all

set $greentext "is only an example"
Tnx in advance,
oxygen
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

set greentext "\00303green text here\003"
\003 stands for mIRC's ctrl+k code.
o
oxygen
Voice
Posts: 22
Joined: Mon Sep 05, 2005 2:22 pm
Location: Germany

Post by oxygen »

Hello Sir_Fz

Tnx for your reply. I know that. ;)
Wat I'm searching for is to grab the colored words from a text. Not the entire sentence, only the green colored words. Since english is not my native language, it's a little difficult to explain. Sorry..

~oxygen
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

proc grapgreen str {
 set greentext {}
 foreach token [lrange [split $str \003] 1 end] {
  if {[regsub {^(0?)3(,[0-9]{1,2})?} $token "" token]} {
   lappend greentext $token
  }
 }
 set greentext
}
Usage:

Code: Select all

grapgreen <text>
this should return a list of green text.
o
oxygen
Voice
Posts: 22
Joined: Mon Sep 05, 2005 2:22 pm
Location: Germany

Post by oxygen »

Hello Sir_Fz

It's exactly what I was lookin' for. Works fine :)

Tnx alot.

~oxygen
o
oxygen
Voice
Posts: 22
Joined: Mon Sep 05, 2005 2:22 pm
Location: Germany

Post by oxygen »

Hello,

I have a problem with the stored text. I store the greentext with:

Code: Select all

        set fd [open $log_greentext a+]
        puts $fd "$greentext"
        close $fd
In the stored file, the text is filled with ? between the words.
Example: "This is?an?example of the?green?text."
With "putlog" in the bots partyline I can't see any ?. Can anybody help pls.

Tnx,
~oxygen
o
oxygen
Voice
Posts: 22
Joined: Mon Sep 05, 2005 2:22 pm
Location: Germany

Post by oxygen »

Hello

Seems that this behavior is only under windrop. I uploaded my script on my eggdrop, and there is all ok.


Tnx,
~oxygen
Post Reply