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.

about caps and normal

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
ultralord
Master
Posts: 255
Joined: Mon Nov 06, 2006 6:52 pm

about caps and normal

Post by ultralord »

hello.. i make one script and i set some variables and then i save them on the txt ( variables is nicks when someone run some binds his nick is on txt) all is ok.. but when i run some procs to count info from txt how many times nicks is displayed the bot dont count the nick because the nick is typing with caps ..

example:

my nick : Ultralord , i press !lalala
bot adds my nick Ultralord on txt
if i use my nick like ULTRALORD (with caps) my bot when i press the bind to show me the count results doesnt count all info from my nick Ultralord and ULTRALORD etc.


thanks i need to fix that is very usefull , thanks again
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

u mean that Ultralord and ULTRALORD are two diffrent nicks for bot?

try to:

Code: Select all

[string tolower $string]
before count, after this all nicks will be with small letters

:>
User avatar
ultralord
Master
Posts: 255
Joined: Mon Nov 06, 2006 6:52 pm

Post by ultralord »

thanks for reply.

cant counting both words like Ultralord and ULTRALORD like one result?
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

ultralord wrote:thanks for reply.

cant counting both words like Ultralord and ULTRALORD like one result?
without tricks like [string tolower] i think no, because it is like in Unix systems, BIG_CHAR != small_char then ULTRALORD != Ultralord

put somewhere [string tolower] or "toupper" etc and all will be fine :)
User avatar
ultralord
Master
Posts: 255
Joined: Mon Nov 06, 2006 6:52 pm

Post by ultralord »

ok i edited now and all nicks are on small letters the problem is some procs worked without $nick and i cant set it the string so how i can make that proc to work ?

Code: Select all

proc g_mygames {nickname hand idx args} {
  global g_plstats g_pickupchan g_stats
           if { [matchattr $idx L] } { 
 if {[llength $g_stats]==0} {
    putserv "NOTICE $nickname :No Gather yet :)"
    return 0
  }
  set stats $g_stats
  set results [list ]
  while {[llength $stats]!=0} {
    set match [lindex $stats 0]
    set counter 0
    set temp [list ]
    set temp [linsert $temp end $match]
    while {[lsearch -exact $stats $match]>-1} {
      incr counter
      set pos [lsearch -exact $stats $match]
      set stats [lreplace $stats $pos $pos]
    }
    set temp [linsert $temp end $counter]
    set results [linsert $results end $temp]
  }
  set results [lsort -integer -decreasing -index 1 $results]
  set counter 1
  #  putquick "NOTICE $nickname :1,0«1,15«1,14«0,1  Top 10 gather players. 1,14»1,15»1,0»"
  foreach result $results {
    if { [matchattr $idx G] } {
    set admin0r 1
    } else { 
    set admin0r 0
   }
    if {$nickname == [lindex $result 0]} {
    if {$admin0r == 1} {
    putquick "NOTICE $nickname :14,1\[7«0 You make ([lindex $result 0]) : [lindex $result 1] gathers this month. Rank:  $counter. Status: Admin. 7»14]"
   } else {
    putquick "NOTICE $nickname :14,1\[7«0 You make ([lindex $result 0]) : [lindex $result 1] gathers this month. Rank: 4 $counter0,1. Status: 4Admin0,1. 7»14]"
    }
    }
    incr counter
}
} else {
if {[llength $g_stats]==0} {
    putserv "NOTICE $nickname :No Gather yet :)"
    return 0
  }
  set stats $g_stats
  set results [list ]
  while {[llength $stats]!=0} {
    set match [lindex $stats 0]
    set counter 0
    set temp [list ]
    set temp [linsert $temp end $match]
    while {[lsearch -exact $stats $match]>-1} {
      incr counter
      set pos [lsearch -exact $stats $match]
      set stats [lreplace $stats $pos $pos]
    }
    set temp [linsert $temp end $counter]
    set results [linsert $results end $temp]
  }
  set results [lsort -integer -decreasing -index 1 $results]
  set counter 1
  #  putquick "NOTICE $nickname :1,0«1,15«1,14«0,1  Top 10 gather players. 1,14»1,15»1,0»"
  foreach result $results {
    if { [matchattr $idx G] } {
    set admin0r 1
    } else { 
    set admin0r 0
   }
    if {$nickname == [lindex $result 0]} {
    if {$admin0r == 1} {
    putquick "NOTICE $nickname :14,1\[7«0 You make ([lindex $result 0]) : [lindex $result 1] gathers this month. Rank:  $counter. Status: Admin. 7»14]"
   } else {
    putquick "NOTICE $nickname :14,1\[7«0 You make ([lindex $result 0]) : [lindex $result 1] gathers this month. Rank: 4 $counter0,1. Status: 4Admin0,1. 7»14]"
    }
    }
    incr counter
       }
}
}

he count how many times the nick is on txt file and he announce the result.. but i must have the nick with small letters because i cant setup
set nick [string tolower $nick] or something.. any opinion?


thnx
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

ultralord wrote:ok i edited now and all nicks are on small letters the problem is some procs worked without $nick and i cant set it the string so how i can make that proc to work ?
why u can't?
put after proc definition set nick [string tolower $nick] this will overwrite the nick var with small letters nick, or set nickname [string tolower $nickname] whatever, after this all nicks will be "small"

can u paste whole script and some manual how to use it? I want to try it :)

[edit]

ok I checked this proc, I wrote to "g_stats" {nick Nick NICK} and after:
g_mygames "nick" "" "" ""
[tomekk@zonk]:/home# ./proc.tcl
NOTICE nick :^C14,1[^C7?^C0 You make (nick) : 1 gathers this month. Rank: 1. Status: Admin. ^C7?^C14]
I wrote tiny proc to lower all nicks in this list, and I put it here:

Code: Select all

proc g_mygames {nickname hand idx args} { 
  global g_plstats g_pickupchan g_stats

  #here
   g_stats_to_lower

   if { [matchattr $idx L] } {
     ....

after that i got:
NOTICE nick :^C14,1[^C7?^C0 You make (nick) : 3 gathers this month. Rank: 1. Status: Admin. ^C7?^C14]
here is this proc code:

Code: Select all

proc g_stats_to_lower { } {
        global g_stats

        set temp_low [list]

        foreach big_stat $g_stats {
                if {$big_stat != ""} {
                        set need_low_nick [string tolower $big_stat]
                        lappend temp_low $need_low_nick
                }
        }

        set g_stats $temp_low
}
:>
User avatar
ultralord
Master
Posts: 255
Joined: Mon Nov 06, 2006 6:52 pm

Post by ultralord »

i put first the string [string tolower $nick] etc.. but nothing no lucky .. i try your proc etc but works if i have nick with small letters like ultralord if i have Ultralord doesnt work..

also i am sorry icant paste all the code..
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

damn, i wish to help u :)

I just can't get what you mean with this Ultra, ultra .. I rly see no problem to lower nick letters, even if he use some trigger like !test what is the problem to lower the $nick from proc input?

like u wrote, set nick [string tolower $nick] and all input nicks will be with small letters, set low_nick [string tolower $nick] or smth,

I just wanted the source to check what is going on but no problem.


///
[tomekk@zonk]:/home# ./proc.tcl Nick
i just added "set nickname [string tolower $nickname]"
[tomekk@zonk]:/home# ./proc.tcl Nick
NOTICE nick :^C14,1[^C7?^C0 You make (nick) : 3 gathers this month. Rank: 1. Status: Admin. ^C7?^C14]
all input nicks are "small" and all nicks in list are "small" too :>
User avatar
ultralord
Master
Posts: 255
Joined: Mon Nov 06, 2006 6:52 pm

Post by ultralord »

look to explain you better..

i have nick Ultralord and i press !mygames then the bot counting the txt file how many times nick Ultralord is on txt and announce the result.. and when i have nick ULTRALORD and i press !mygames doesnt announce anything because all nicks on txt is Ultralord and not ULTRALORD.. then after your 1st helpful post i put set nick [string tolower $nick] before my procs and now on txt write only nicks with small letters good.. the next problem is. if i have nick Ultralord cant counting because i have Ultralord and not ultralord because "ultralord" is on txt with small letters .. thats the latest problem :/ but if we find the solution from another way.. like new proc and his work is to count how many times is his nick on txt file and he announce the result and counting small and big letters ..

thanks for your help at all
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

okey,

then what is the problem to [string tolower] all data from txt file? after that all will be the same
User avatar
ultralord
Master
Posts: 255
Joined: Mon Nov 06, 2006 6:52 pm

Post by ultralord »

i dotn underestand what you mean..i try before your solution and the problem is one.. all nicks on txt is with small letters and bot response the answer for counting if i had ultralord (with small letters) if i run proc for counting with Ultralord with one or more letters with caps doesnt response
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

ultralord wrote:i dotn underestand what you mean..i try before your solution and the problem is one.. all nicks on txt is with small letters and bot response the answer for counting if i had ultralord (with small letters) if i run proc for counting with Ultralord with one or more letters with caps doesnt response
ehh its simple bug :P

if u run this !mygames or smth with nick "Ultralord" then your nick in script will be "Ultralord" (its normal because u run it from Ultralord and $nick in proc will be the same, with case sensitivity), u just need to lower this nick at the beginning and all other nicks, from file, from other variables too, if all data sources are "small" then there is no chance that nick != nick :)
User avatar
ultralord
Master
Posts: 255
Joined: Mon Nov 06, 2006 6:52 pm

Post by ultralord »

yes but i put set nick [string tolower $nick] in the brgging of proc to have small letters but i dont unterestand why doesnt work.. something on proc reads the nick and not the string of small letters


tnx
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

if u dont want to post the source here feel free to PM me with it, I can try to fix it, np for me :)

HF :)
Post Reply