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.
Old posts that have not been replied to for several years.
jimmyx
Voice
Posts: 11 Joined: Mon Jul 14, 2003 6:51 pm
Post
by jimmyx » Fri Aug 08, 2003 5:41 pm
I was wondering it was possible to change 1 text string (for example: bob is cool) and make it into 3 seperate strings, bob, is, and cool. How would I go about doing this? I've used the search function, but I didn't find anything that could help, well..that I could understand.
I guess that wasn't really that clear, so what im trying to do is having people message the bot with: !add bob is cool and having it put in the text file I set, but like this:
[word1]
bob
[word2]
is
[word3]
cool
Is it possible?
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Sat Aug 09, 2003 1:19 am
How about this:
Code: Select all
set word1 [lindex $text 0]
set word2 [lindex $text 1]
set word3 [lindex $text 2]
Once the game is over, the king and the pawn go back in the same box.
jimmyx
Voice
Posts: 11 Joined: Mon Jul 14, 2003 6:51 pm
Post
by jimmyx » Sat Aug 16, 2003 7:33 pm
I'm guessing its either a stupid noob mistake -- or I should start reading up the tcl documentation some more. But here's a snipplet of what I have:
Code: Select all
proc addstrings {nick uhost w1 w2 w3 text} {
global mainchan file
putserv "NOTICE $mainchan : $nick ( $uhost ) adding $text to $file"
set fs [open strings.txt w]
set w1 [lindex $text 0]
set w2 [lindex $text 1]
set w3 [lindex $text 2]
puts $fs "1. $w1 2. $w2 3. $w3"
close $fs
putserv "NOTICE $mainchan : $text added."
return 1
}
It won't write anything to strings.txt..
I have addstrings binded to a msg, could that be why its not working? what could i use other than $text?
I've just recently started messing around with tcl..so I don't really understand much.
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Sat Aug 16, 2003 8:16 pm
try adding this : set text [split $text] (I think that the bot must split the text before using [lindex....])
strikelight
Owner
Posts: 708 Joined: Mon Oct 07, 2002 10:39 am
Contact:
Post
by strikelight » Sat Aug 16, 2003 11:30 pm
jimmyx wrote: I'm guessing its either a stupid noob mistake -- or I should start reading up the tcl documentation some more. But here's a snipplet of what I have:
Code: Select all
proc addstrings {nick uhost w1 w2 w3 text} {
global mainchan file
putserv "NOTICE $mainchan : $nick ( $uhost ) adding $text to $file"
set fs [open strings.txt w]
set w1 [lindex $text 0]
set w2 [lindex $text 1]
set w3 [lindex $text 2]
puts $fs "1. $w1 2. $w2 3. $w3"
close $fs
putserv "NOTICE $mainchan : $text added."
return 1
}
It won't write anything to strings.txt..
I have addstrings binded to a msg, could that be why its not working? what could i use other than $text?
I've just recently started messing around with tcl..so I don't really understand much.
I'm guessing you see an error in the partyline saying something to the effect of: "proc addstrings called with not enough arguments"
Consult doc/tcl-commands.doc for the # of parameters a msg bound proc must have.
jimmyx
Voice
Posts: 11 Joined: Mon Jul 14, 2003 6:51 pm
Post
by jimmyx » Sun Aug 17, 2003 6:05 pm
I got it.
Thanks for your help, guys.