egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

adding numeric values.

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
iamdeath
Master


Joined: 11 Feb 2005
Posts: 323
Location: *HeLL*

PostPosted: Tue Jun 06, 2006 1:42 pm    Post subject: adding numeric values. Reply with quote

Question 1:
Code:
proc relay:text {nick uhost handle chan text} {
  global relay
  if {[isop $nick $chan] == "1"} {
    if {[string range "$nick" 0 0] != "^"} {return 0}
#    if {[string match "*m*" [getchanmode $chan]] == "0"} { return 0 }
    foreach badpub $relay(badpubs) { if {[string match "$badpub" [string tolower $text]] == "1"} { return 0 } }
    regsub -all {FOUR} $text "10,09FOUR" text
    regsub -all {SIX} $text "11,12SIX" text
    regsub -all {OUT} $text "04,01OUT" text
    if {[string range "$nick" 0 0] == "^"} { set nick "[string range "$nick" 1 end]" }
    if {[llength [split $nick "_"]] == "2" && [lindex [split $nick "_"] 0] != "" && [lindex [split $nick "_"] 1] != ""} { set nick "[lindex [split $nick "_"] 0] VS [lindex [split $nick "_"] 1]" }
    relay:send "PRIVMSG $relay(channel_out) :$nick: $text"
}



Quote:
regsub -all {FOUR} $text "10,09FOUR" text
regsub -all {SIX} $text "11,12SIX" text
regsub -all {OUT} $text "04,01OUT" text


When the bot recieves the word FOUR SIX AND OUT, it changes the color pattern of it and shows in the channel. The way "FOUR, SIX & OUT" are added, I want something like:

Quote:
regsub -all {0} $text "NO RUN" text
regsub -all {1} $text "ONE RUN" text
regsub -all {2} $text "TWO RUNS" text


I tried that but giving me error.. What could be the best way adding numeric values?

Question 2:

If you get a Nickname like :

NICK_NICK_ and I want to make it NICK VS NICK: how will you do that? can you help me out ?
Somethign like this:?

Code:
    if {[llength [split $nick "_"]] == "2" && [lindex [split $nick "_"] 0] != "" && [lindex [split $nick "_"] 1] != ""} { set nick "[lindex [split $nick "_"] 0] VS [lindex [split $nick "_"] 1]" }


Thanks.
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Tue Jun 06, 2006 6:50 pm    Post subject: Reply with quote

advice: don't use regsub on simple string replaces without regular expressions. String map does fine in both cases. Though I am not sure why there should be an error, because of that line. Get the complete errorInfo (refer Help us to help you).

About the NICK_NICK_ thing... I advice you to actually try what such statements do:
Code:
% set list [split NICK_NICK_ _]
NICK NICK {}
% llength $list
3

_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
iamdeath
Master


Joined: 11 Feb 2005
Posts: 323
Location: *HeLL*

PostPosted: Wed Jun 07, 2006 5:20 am    Post subject: Reply with quote

Did'nt understand I am sorry ;/
Back to top
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Wed Jun 07, 2006 6:34 am    Post subject: Reply with quote

With a "didnt understand" I am unable to help you. You must be more specific about the part you did not understand. If you did not understand at all, I suggest visiting some English lessons... though you wouldn't be able to understand then that suggestion, either Very Happy.
I make a wild guess and give the link to the string map manual.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber