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 

Binds to msg and pub allow scripts to interact - SOLVED

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


Joined: 05 Jan 2008
Posts: 10

PostPosted: Mon Feb 07, 2011 1:19 pm    Post subject: Binds to msg and pub allow scripts to interact - SOLVED Reply with quote

I have had trouble formulating a good subject line for this question, but it comes down to the fact that I must have a fundamental misunderstanding of binds. Can anyone explain to me please what I am doing wrong here? I have written two scripts (mychann.tcl and mychann_ops.tcl). As you might expect, mychann.tcl runs in #mychann and mychann_ops.tcl runs in #mychann_ops. The same bot is present in both channels.

The scripts do essentially the same thing and have a lot of procs in common, but they have different binds. mychann.tcl is bound to msg like this :
Code:
bind msg - !foo get_message
On the other hand mychann_ops.tcl is bound to pub like this:
Code:
bind pub - !foo get_message
As I understood things, this should have been enough to keep each script to its own channel and function.

What I find, however, is that the command !foo when issued in #mychann_ops also triggers mychann.tcl in #mychann - which then throws an error message because of the different number of args expected by get_message when bound to msg as opposed to being bound to pub. Both scripts then terminate. I am thinking of workarounds, but I am really puzzled as to why this behaviour occurs at all, when they have different binds.


Last edited by silenus on Mon Feb 07, 2011 4:28 pm; edited 1 time in total
Back to top
View user's profile Send private message
Papillon
Owner


Joined: 15 Feb 2002
Posts: 724
Location: *.no

PostPosted: Mon Feb 07, 2011 1:37 pm    Post subject: Reply with quote

You are sort of answering your own question. There are indeed two different binds, but they are both bound to the same procedure, or to two different procedures called by the same name... this will always cause troubles.

get_message rename one of them and they will not interfere with eachother
_________________
Elen sila lúmenn' omentielvo
Back to top
View user's profile Send private message MSN Messenger
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon Feb 07, 2011 3:52 pm    Post subject: Reply with quote

@silenus : post some code where you're stuck.

@Papillon Shocked OMG! Are you the Papillon i know? Very Happy Dude, where you've been all this time? Razz Rolling Eyes
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Mon Feb 07, 2011 4:01 pm    Post subject: Reply with quote

Also, see:

http://forum.egghelp.org/viewtopic.php?t=12900
Back to top
View user's profile Send private message
silenus
Voice


Joined: 05 Jan 2008
Posts: 10

PostPosted: Mon Feb 07, 2011 4:27 pm    Post subject: Reply with quote

Thank-you all for prompt and helpful responses. After papillon replied I had tried changing the names of the procedures attached to binds, but I was still experiencing a problem with a global variable (same name in both scripts), and now I am having a further problem with another variable (also same name in both scripts). I have feeling that the dominoes will continue to fall as fixing one problem reveals another. I know that these scripts work separately, so the problem must be with their interaction, and it seems that I would be better spending my time learning about the namespaces to which willyw draws my attention than fiddling with names of procs and variables. For this reason caesar, I don't think it would help for me to take up your time by posting code here.

Thanks again - I will mark this "solved"
Back to top
View user's profile Send private message
silenus
Voice


Joined: 05 Jan 2008
Posts: 10

PostPosted: Mon Feb 07, 2011 6:14 pm    Post subject: Reply with quote

Just a short note about the outcome. After half an hour learning about namespaces my scripts now work together without any problems. Smile
Back to top
View user's profile Send private message
Papillon
Owner


Joined: 15 Feb 2002
Posts: 724
Location: *.no

PostPosted: Tue Feb 08, 2011 12:19 pm    Post subject: Reply with quote

@silenus: Good that you solved it. It is just to remember that when you name a global variable or procedure, that name is truly global in your bot. You may have a procedure in one script, but call it from another script. Namespaces helps solve this problem if used correctly Smile

@caesar: it is me ye, been studying and generally having a real life once more Smile
_________________
Elen sila lúmenn' omentielvo
Back to top
View user's profile Send private message MSN Messenger
silenus
Voice


Joined: 05 Jan 2008
Posts: 10

PostPosted: Tue Feb 08, 2011 1:34 pm    Post subject: Reply with quote

@Papillon Yes. There are no bugs, only lessons. I am a very amateur programmer and had no clear idea of the way in which scripts work within the bot. I saw them as little packages, ring-fenced by the bind which calls them. I know better now.
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