| View previous topic :: View next topic |
| Author |
Message |
mrNobody Voice
Joined: 02 Dec 2013 Posts: 14
|
Posted: Mon Dec 02, 2013 5:30 am Post subject: Confide trigger to a script |
|
|
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: |
#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: |
#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: |
#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. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Mon Dec 02, 2013 12:20 pm Post subject: Re: Confide trigger to a script |
|
|
| 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.
| Quote: |
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: |
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. |
|
| Back to top |
|
 |
mrNobody Voice
Joined: 02 Dec 2013 Posts: 14
|
Posted: Sat Dec 21, 2013 11:51 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sun Dec 22, 2013 10:53 am Post subject: |
|
|
What about something like:
| Code: |
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. |
|
| Back to top |
|
 |
mrNobody Voice
Joined: 02 Dec 2013 Posts: 14
|
Posted: Mon Dec 23, 2013 4:08 am Post subject: |
|
|
| yeah that's how I fixed it eventually, thanks for the input :) |
|
| Back to top |
|
 |
|