Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

multiple llListen/listen

Alicia Sautereau
if (!social) hide;
Join date: 20 Feb 2007
Posts: 3,125
04-12-2007 06:25
hiya

just started to modify some freebie scripts to alter them to my specific needs but have encounterd a small problem when trying multiple listenings on diff channels

state_entry() {
llListen(channel, "", "", "";);
llListen(dc_channel, "", "", "";);
}

listen(integer dc_channel, string name, key id, string msg)
{
blablabla
}

listen(integer channel, string name, key id, string msg)
{
blabla bla
}


only the first llListen is working and executing commands but the dc_channel is being ignored, functions in it works as they have been moved from the normal channel after creating the dc_channel so that isn`t the problem :)

why, modified a single multiprim door to be working as a double door set with the open/close command on the normal channel as there will be more doors in llwhisper range, but i want to have all doors listen to the added lock/unlock channel so i don`t have to create a scripts to llshout the commands on each door channel but just on 1 general channel (if that makes sense :))

just started scripting yesterday so be gentle ;)
thx in advance
Ged Larsen
thwarted by quaternions
Join date: 4 Dec 2006
Posts: 294
04-12-2007 07:00
From: Alicia Sautereau
hiya

just started to modify some freebie scripts to alter them to my specific needs but have encounterd a small problem when trying multiple listenings on diff channels

CODE
state_entry() {
llListen(channel, "", "", "");
llListen(dc_channel, "", "", "");
}

listen(integer dc_channel, string name, key id, string msg)
{
blablabla
}

listen(integer channel, string name, key id, string msg)
{
blabla bla
}


only the first llListen is working and executing commands but the dc_channel is being ignored, functions in it works as they have been moved from the normal channel after creating the dc_channel so that isn`t the problem :)


You can only have one listen() event handler per state, so consolidate your two listen even handlers into one. I'd recommend using a different variable name, for the variables that are passed to the event handler.

So, maybe:
CODE
listen (integer heardChan, string name, key id, string msg)
{
if (heardChan == channel)
{ DO STUFF }
else if (heardChan == dc_channel)
{ DO OTHER STUFF }
}

Something like that.
_____________________
- LoopRez, flexi prim skirt generating tool
- LinkRez, a necklace chain generator
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
04-12-2007 07:14
Rather than use multiple channels why not modify the doors so each pair work on seperate ID's which you can pass as part of the message string?
Alicia Sautereau
if (!social) hide;
Join date: 20 Feb 2007
Posts: 3,125
04-12-2007 07:24
ty Ged, that worked like a charm, all door sets now command their counter part on a diff channel not to open/close other doors and they all listen on the command channel for lock/unlock :P