| View previous topic :: View next topic |
| Author |
Message |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Fri Nov 27, 2009 4:58 pm Post subject: help please[solved] |
|
|
Hey can someone help with this code i keep getting errors when i try starting my eggie
also when i do the command !next i have to put the lnie number is it possible to just do !next without line number so it will read each line seperate this used to work but has been messed up somewere
| Code: | [15:49] Tcl error in file 'eggdrop.conf':
[15:49] missing close-brace
while executing
"proc next_proc { nick uhost hand chan arg } {
global out_chan txt_file
set line [lindex [split $arg] 0]
if {$line == ""} {
putserv "PRIVMSG $chan..."
(file "scripts/training.tcl" line 6)
invoked from within
"source scripts/training.tcl"
(file "eggdrop.conf" line 1332)
[15:49] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR) |
| Code: | set out_chan "#Trainingroom"
set txt_file "Training.txt"
bind pub SA|SA !next next_proc
bind pub SA|SA !back back_proc
proc next_proc { nick uhost hand chan arg } {
global out_chan txt_file
set line [lindex [split $arg] 0]
if {$line == ""} {
putserv "PRIVMSG $chan :Usage: !next <linenumber>"
return
}
set take_me [open $txt_file r]
set take_all [split [read $take_me] "\n"]
close $take_me
}
foreach txt_line $take_all {
if {$txt_line != ""} {
putquick "PRIVMSG $out_chan :$txt_line"
}
}
proc back_proc { nick uhost hand chan arg } {
global out_chan txt_file
set line [lindex [split $arg] 0]
if {$line == ""} {
putserv "PRIVMSG $chan :Usage: !back <line number>"
return
}
set take_me [open $txt_file r]
set take_all [split [read $take_me] "\n"]
close $take_me
set data [lindex $take_all [expr $line - 1]]
putquick "PRIVMSG $out_chan :$data"
}
}
|
_________________ Blake
UKEasyHosting UKStormWatch
Last edited by blake on Thu Dec 17, 2009 3:51 pm; edited 3 times in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Nov 27, 2009 5:31 pm Post subject: |
|
|
You've got a few unbalanced braces in there..
Indent the code properly, and it should be alot simpler to see where they're missing.. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Fri Nov 27, 2009 6:23 pm Post subject: |
|
|
| nml375 wrote: | You've got a few unbalanced braces in there..
Indent the code properly, and it should be alot simpler to see where they're missing.. |
I`ve put it back to how I think it should have been unfortunetly the original script I had was on computer that went bang _________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Nov 27, 2009 6:29 pm Post subject: |
|
|
If I were to properly indent your last code snippet, it would look like this:
| Code: | set out_chan "#Trainingroom"
set txt_file "Training.txt"
bind pub SA|SA !next next_proc
bind pub SA|SA !back back_proc
proc next_proc { nick uhost hand chan arg } {
global out_chan txt_file
set line [lindex [split $arg] 0]
if {$line == ""} {
putserv "PRIVMSG $chan :Usage: !next <linenumber>"
return
}
set take_me [open $txt_file r]
set take_all [split [read $take_me] "\n"]
close $take_me
}
foreach txt_line $take_all {
if {$txt_line != ""} {
putquick "PRIVMSG $out_chan :$txt_line"
}
}
proc back_proc { nick uhost hand chan arg } {
global out_chan txt_file
set line [lindex [split $arg] 0]
if {$line == ""} {
putserv "PRIVMSG $chan :Usage: !back <line number>"
return
}
set take_me [open $txt_file r]
set take_all [split [read $take_me] "\n"]
close $take_me
set data [lindex $take_all [expr $line - 1]]
putquick "PRIVMSG $out_chan :$data"
}
} |
In this case, you've got the foreach-loop outside the next_proc proc, I suppose that's not what you intended. Also, there's one stray } after the back_proc proc. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Fri Nov 27, 2009 6:36 pm Post subject: |
|
|
Removed the extra brace now get this error
| Code: | [17:34] can't read "take_all": no such variable
while executing
"foreach txt_line $take_all {
if {$txt_line != ""} {
putquick "PRIVMSG $out_chan :$txt_line"
}
}" | [/code] _________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Fri Nov 27, 2009 6:41 pm Post subject: |
|
|
| blake wrote: | Removed the extra brace now get this error
| Code: | [17:34] can't read "take_all": no such variable
while executing
"foreach txt_line $take_all {
if {$txt_line != ""} {
putquick "PRIVMSG $out_chan :$txt_line"
}
}" | [/code] |
removed the brace before foreach this is how its looking getting no errors
| Code: | set out_chan "#Trainingroom"
set txt_file "Training.txt"
bind pub SA|SA !next next_proc
bind pub SA|SA !back back_proc
proc next_proc { nick uhost hand chan arg } {
global out_chan txt_file
set line [lindex [split $arg] 0]
if {$line == ""} {
putserv "PRIVMSG $chan :Usage: !next <linenumber>"
return
}
set take_me [open $txt_file r]
set take_all [split [read $take_me] "\n"]
close $take_me
foreach txt_line $take_all {
if {$txt_line != ""} {
putquick "PRIVMSG $out_chan :$txt_line"
}
}
proc back_proc { nick uhost hand chan arg } {
global out_chan txt_file
set line [lindex [split $arg] 0]
if {$line == ""} {
putserv "PRIVMSG $chan :Usage: !back <line number>"
return
}
set take_me [open $txt_file r]
set take_all [split [read $take_me] "\n"]
close $take_me
set data [lindex $take_all [expr $line - 1]]
putquick "PRIVMSG $out_chan :$data"
}
} |
_________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Fri Nov 27, 2009 6:52 pm Post subject: |
|
|
Have sorted it so its outputting the text of the file any help with line numbers i want to be able to just type !next and it display the next line without having to do !next linenumber _________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Nov 27, 2009 7:08 pm Post subject: |
|
|
Code still looks broken, and your braces {} are still out of order..
You currently get away with it if you execute !next atleast once before executing !back, since you actually managed to nest back_proc inside next_proc.
This is how it should look, and the point of indenting is to keep track of how many "nested" braces you've got.. add one {, indent one step more.. add one }, indent one step less...
| Code: | set out_chan "#Trainingroom"
set txt_file "Training.txt"
bind pub SA|SA !next next_proc
bind pub SA|SA !back back_proc
proc next_proc { nick uhost hand chan arg } {
global out_chan txt_file
set line [lindex [split $arg] 0]
if {$line == ""} {
putserv "PRIVMSG $chan :Usage: !next <linenumber>"
return
}
set take_me [open $txt_file r]
set take_all [split [read $take_me] "\n"]
close $take_me
foreach txt_line $take_all {
if {$txt_line != ""} {
putquick "PRIVMSG $out_chan :$txt_line"
}
}
}
proc back_proc { nick uhost hand chan arg } {
global out_chan txt_file
set line [lindex [split $arg] 0]
if {$line == ""} {
putserv "PRIVMSG $chan :Usage: !back <line number>"
return
}
set take_me [open $txt_file r]
set take_all [split [read $take_me] "\n"]
close $take_me
set data [lindex $take_all [expr $line - 1]]
putquick "PRIVMSG $out_chan :$data"
} |
For your !next without linenumbers, you'd have to keep a counter for the displayed line. Should this be user-specific, channel-specific, global, or something else? _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Fri Nov 27, 2009 7:36 pm Post subject: |
|
|
it would channel specific its only used in one room which is #trainingroom and only has one person at anyone time using it _________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Mon Nov 30, 2009 8:53 pm Post subject: |
|
|
slitely changed this script again as it was sending the hole file to channel
id like to be able to change it so the command !tr without linenumber can be typed in the bots pm will still need to read one line at a time fron text file currently we have to type !tr line number in the channel the bot is in the back proc is ok but if that could be set so we can type that in pm also would be great line nimber needs to remain for back proc
| Code: | set out_chan "#Trainingroom"
set txt_file "training.txt"
bind pub SA|SA !tr next_proc
bind pub SA|SA !back back_proc
proc tr_proc { nick uhost hand chan arg } {
global out_chan txt_file
set line [lindex [split $arg] 0]
if {$line == ""} {
putserv "PRIVMSG $chan :Usage: !tr <line number>"
return
}
set take_me [open $txt_file r]
set take_all [split [read $take_me] "\n"]
close $take_me
set data [lindex $take_all [expr $line - 1]]
putquick "PRIVMSG $out_chan :$data"
}
proc back_proc { nick uhost hand chan arg } {
global out_chan txt_file
set line [lindex [split $arg] 0]
if {$line == ""} {
putserv "PRIVMSG $chan :Usage: !back <line number>"
return
}
set take_me [open $txt_file r]
set take_all [split [read $take_me] "\n"]
close $take_me
set data [lindex $take_all [expr $line - 1]]
putquick "PRIVMSG $out_chan :$data"
}
|
_________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
|