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.

A trigger notice script (newb need some help)[SOLVED]

Help for those learning Tcl or writing their own scripts.
Post Reply
i
ipone
Voice
Posts: 13
Joined: Mon Mar 20, 2006 7:00 am

A trigger notice script (newb need some help)[SOLVED]

Post by ipone »

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: Select all

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.
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

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: Select all

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: Select all

if {[string equal -nocase $channel $firstchannel]} {
You also need another " if your putquick statement at the end.


Code: Select all

putquick "notice $nickname :$channelmsg"
The return 0 is not needed.

So the end code should look like:

Code: Select all

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
i
ipone
Voice
Posts: 13
Joined: Mon Mar 20, 2006 7:00 am

Post by ipone »

ooh sweet. thanks. now i know little more about tcl-scripting. this forum is going to be verry usefull :D
Post Reply