| View previous topic :: View next topic |
| Author |
Message |
ipone Voice
Joined: 20 Mar 2006 Posts: 13
|
Posted: Wed Jun 27, 2007 3:27 am Post subject: A trigger notice script (newb need some help)[SOLVED] |
|
|
Hey im a total newb when it comes to tcl scripting for eggdrops.
I was trying to make a simpel trigger script for multiple channels
i know its already have been done and i can download it and add it to the bot.
but i figerd that if i want to learn tcl i need to do i myself.
| Code: |
set trigger "!help"
set firstchannel "#test"
set channelmsg "need some help?"
bind pub - $trigger trigger1
proc trigger1 {nickname hostname handle channel text} {
if {$channel == $firstchannel} {
putquick "notice $nickname :$channelmsg
}
return 0
}
|
ive would be verry happy if someone can help me with this. not just say how the code must be, also maybe try to explain why and so on.
btw. sry for bad english
Last edited by ipone on Wed Jun 27, 2007 6:03 pm; edited 1 time in total |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Wed Jun 27, 2007 10:42 am Post subject: |
|
|
the reason it does not work is that the firstchannel and channelmsg variables are set outside the proc, meaning they are in global space. The firstchannel and channelmsg variables are within the proc, which is not in global space. You need to import the firstchannel and channelmsg variables from global space into the proc. For this you use:
| Code: | | global firstchannel channelmsg |
This will import the global space variables firstchannel and channelmsg into proc space variables firstchannel and channelmsg.
For the if statement, it would be better to use a string equal -nocase, otherwise if the channels dont match case, it wont continue.
| Code: | | if {[string equal -nocase $channel $firstchannel]} { |
You also need another " if your putquick statement at the end.
| Code: | | putquick "notice $nickname :$channelmsg" |
The return 0 is not needed.
So the end code should look like:
| Code: | set trigger "!help"
set firstchannel "#test"
set channelmsg "need some help?"
bind pub - $trigger trigger1
proc trigger1 {nickname hostname handle channel text} {
global firstchannel channelmsg
if {[string equal -nocase $channel $firstchannel]} {
putquick "notice $nickname :$channelmsg"
}
} |
Hope this helps  _________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
ipone Voice
Joined: 20 Mar 2006 Posts: 13
|
Posted: Wed Jun 27, 2007 6:02 pm Post subject: |
|
|
ooh sweet. thanks. now i know little more about tcl-scripting. this forum is going to be verry usefull  |
|
| Back to top |
|
 |
|