egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ipone
Voice


Joined: 20 Mar 2006
Posts: 13

PostPosted: Wed Jun 27, 2007 3:27 am    Post subject: A trigger notice script (newb need some help)[SOLVED] Reply with quote

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
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Wed Jun 27, 2007 10:42 am    Post subject: Reply with quote

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 Smile
_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
ipone
Voice


Joined: 20 Mar 2006
Posts: 13

PostPosted: Wed Jun 27, 2007 6:02 pm    Post subject: Reply with quote

ooh sweet. thanks. now i know little more about tcl-scripting. this forum is going to be verry usefull Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber