| View previous topic :: View next topic |
| Author |
Message |
iNFERNiS Voice
Joined: 21 Aug 2007 Posts: 13
|
Posted: Fri Nov 02, 2007 3:29 pm Post subject: help with read/output file, public trigger |
|
|
I'm very new to tcl and coding in general. I wanted to make a simple script that reads from a textfile, grabs a random line and outputs it to a channel, with a public trigger.
Suffice to say i failed horribly, i'm kind of stuck now. Can someone point me into the right direction?
| Quote: |
bind pub o|o !randtext pub:randtext
proc pub:randtext { } {
putserv "PRIVMSG $channel : randline("randomness.txt")"
}
proc randline {file} {
set fs [open $file r]
set data [read -nonewline $fs]
close $fs
return [lindex $data [expr {int(rand()*[llength $data])}]]
}
|
|
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Fri Nov 02, 2007 8:07 pm Post subject: |
|
|
| Start off with a basic TCL tutorial first, your code doesn't look like TCL to me :p |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Sat Nov 03, 2007 4:46 am Post subject: |
|
|
| metroid wrote: | | Start off with a basic TCL tutorial first, your code doesn't look like TCL to me :p |
That was rude  _________________ |AmDeAtH @ Undernet
Death is only the *Beginning*... |
|
| Back to top |
|
 |
|