Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

multiple channel listen problem

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
12-02-2007 07:05
i cant seam to figure this out, i have 2 commands on 2 diffrent channels and the first one works fine but the command on other channel dosent respond,

CODE

state_entry()
{
llListen(0,"","","");
llListen(-256,"","","");
llSay(0, "Pods Ready");
llMessageLinked(LINK_ALL_CHILDREN , 0, "on", "");
}
listen(integer channel, string name, key id, string message)
{
if(channel == 0)
{
if(message == "launch")
{
llSay(0,"LIFTOFF");
llMessageLinked(LINK_ALL_CHILDREN , 0, "off", "");
llMessageLinked(LINK_ALL_CHILDREN , 0, "close", "");
llSleep(1);
launch();
}
else
{
if(channel == -256)
{
if(message == "die")
{
llDie();
}
}
}
}
}
Solar Alter
Registered User
Join date: 21 Nov 2007
Posts: 30
12-02-2007 08:03
Because your logic is horrible >.> Check your 'IF/ELSE' block.
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
12-02-2007 08:12
You are asking if channel equals -256 when you are inside channel == 0


Solution:
CODE

if (channel == 0)
{

//doStuff

}

else if (channel == -256)
{

//doOtherStuff

}


And that llListen handler listen to every object/agent.
If you want that the object only listens to owner you can do:

CODE

llListen(0,"",llGetOwner(),"");


Or if you want only to listen to a specific object's name:

CODE

llListen(0,"objectName","","");
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-02-2007 09:42
please also remember to use the closing php tags...;)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
12-02-2007 10:22
i id the if else stuff and still refuese to work it is only listening on channel 0 for some reason
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
12-02-2007 10:29
From: Mrc Homewood
i id the if else stuff and still refuese to work it is only listening on channel 0 for some reason

Where exactly are you testing this at? In world? in LSLEditor? I am asking because I have made the suggestion a couple of times now to try using LSLEditor or the lslint site. In LSLEditor, you can hit ctrl D to auto indent and then the problem is staring you in the face. The same problem that Kahiro stated.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
12-02-2007 10:37
im in world

EDIT,

i ran it in lsl editer and i get errors after

state_entry()
{ // Error

and

listen(
{ // error
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
12-02-2007 11:06
Try this:
CODE


listen(integer channel, string name, key id, string message)
{
if(channel == 0)
{
if(message == "launch")
{
llSay(0,"LIFTOFF");
llMessageLinked(LINK_ALL_CHILDREN , 0, "off", "");
llMessageLinked(LINK_ALL_CHILDREN , 0, "close", "");
llSleep(1);
launch();
}
}
else if(channel == -256)
{
if(message == "die")
{
llDie();
}
}
}


You need to pay closer attention to the logic flow, and it helps to indent properly.
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
12-02-2007 11:21
From: Lear Cale
Try this:
CODE


listen(integer channel, string name, key id, string message)
{
if(channel == 0)
{
if(message == "launch")
{
llSay(0,"LIFTOFF");
llMessageLinked(LINK_ALL_CHILDREN , 0, "off", "");
llMessageLinked(LINK_ALL_CHILDREN , 0, "close", "");
llSleep(1);
launch();
}
}
else if(channel == -256)
{
if(message == "die")
{
llDie();
}
}
}
[/ QUOTE]

You need to pay closer attention to the logic flow, and it helps to indent properly.



...and to use the right closing tag, as opposed to none at all. ;P
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-02-2007 11:29
From: Talarus Luan
...and to use the right closing tag, as opposed to none at all. ;P

and not repeat the exact same thing someone else just said? ;) (see post 4)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
12-02-2007 11:34
From: Void Singer
and not repeat the exact same thing someone else just said? ;) (see post 4)


I didn't, since he didn't leave off the closing tag. He used the wrong one by accident.

I CONTRASTED it by referencing the previous error, for irony. :D
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
12-02-2007 11:36
heehee
Talarus was playing with Cale on this one. Cale did exactly what was done before.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-02-2007 11:44
what I can't play too? ::pouts:: (it was obvious he c&p'd it)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
12-02-2007 11:49
Actually, when I quoted it, it broke in my response, for obvious reasons, so I compounded the error even further. :P

I had to go back and edit it and put in a space in the offending [/ QUOTE] tag. :P