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.

Confide trigger to a script

Help for those learning Tcl or writing their own scripts.
Post Reply
m
mrNobody
Voice
Posts: 14
Joined: Mon Dec 02, 2013 4:49 am

Confide trigger to a script

Post by mrNobody »

Hi all,

Reading these forums has helped me a lot, but now I've come across a problem for which I can't find a solution in the search.

I wrote three scripts which all use the same handles. Individually they work fine, but when I load them together on the same bot, only the last loaded script works. I use a udef flag to assign the scripts to a specific channel, and check for that flag in the procs of the script.

How can I make it so that if I use !le on a channel it uses the script assigned to that channel?

Example:

Code: Select all

#This is channel raid, I have enabled the script with .chanset #raid +raid

bind pub - !le1 raid:le1

proc raid:le1 {nick host hand chan args} {
	global raidflag
	if { [channel get $chan $raidflag] } {
		#code
	}
}

Code: Select all

#This is channel oc, I have enabled the script with .chanset #oc +oc

bind pub - !le1 oc:le1

proc oc:le1 {nick host hand chan args} {
	global ocflag
	if { [channel get $chan $ocflag] } {
		#code
	}
}

Code: Select all

#This is channel moc, I have enabled the script with .chanset #moc +moc

bind pub - !le1 moc:le1

proc moc:le1 {nick host hand chan args} {
	global mocflag
	if { [channel get $chan $mocflag] } {
		#code
	}
}
So that all works fine and does what it is supposed to do as long as I only load one script. If I load all three of them, two of the channels stop working. How can I make the bot recognise the trigger on the chan it's on to bind with the script that's running on that chan?

thanks in advance for your replies, and please let me know if you need more info.
w
willyw
Revered One
Posts: 1207
Joined: Thu Jan 15, 2009 12:55 am

Re: Confide trigger to a script

Post by willyw »

mrNobody wrote:
....Individually they work fine, but when I load them together on the same bot, only the last loaded script works.
...
You have:

bind pub - !le1 raid:le1
bind pub - !le1 oc:le1
bind pub - !le1 moc:le1

I suspect that the only one that works, is the last one. It overwrites the previous two.

Do:
.binds *!le1*
in partyline, and list all the binds that contain !le1
I'm thinking that you will find only one.

Do:
.help binds
to read more about how to use that command in the partyline.



How can I make it so that if I use !le on a channel it uses the script assigned to that channel?
Depends on which way you want to go.
One way would be to use a different bind for each proc.
!le1
!le2
!le3
or something like that.

If you must use only one bind, (and thus one command) then you'll have to have one proc that corresponds to that command. Within that procedure will be the code that does the selecting.

Code: Select all

if {$chan == "$raid"} {
      do stuff here
    }

if {$chan == "#oc"} {
    do other stuff here
    }

There are probably a variety of ways to code the selection process.
This way just came to mind.

I hope this helps.
m
mrNobody
Voice
Posts: 14
Joined: Mon Dec 02, 2013 4:49 am

Post by mrNobody »

Thank you for this input willyw, now I know what I want is not possible xD.

I have combined all three scripts into one and switched it in one proc, like your second suggestion said.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

What about something like:

Code: Select all

bind pub - !le1 all:le1

proc all:le1 {nick host hand chan text} {
	if {[channel get $chan raid]} {
		#code to be executed on +raid channels
	}
	elseif {[channel get $chan oc]} {
		#code to be executed on +oc channels
	}
	elseif {[channel get $chan moc]} {
		#code to be executed on +moc channels
	}
} 
If you happen to have two or three of this flags active on a channel then replace the elseif with an if.
Once the game is over, the king and the pawn go back in the same box.
m
mrNobody
Voice
Posts: 14
Joined: Mon Dec 02, 2013 4:49 am

Post by mrNobody »

yeah that's how I fixed it eventually, thanks for the input :)
Post Reply