Jump to content

Listen to more than 1 channel?


Suki Hirano
 Share

You are about to reply to a thread that has been inactive for 3202 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

How do I get a script to listen to more than 1 channel? I have an object that has 2 scripts itself, as well as a HUD that sends it messages. I'd like the main script of the object to listen to both message sent by the HUD (channel_dialog1) and the secondary script in itself (channel_dialog2):

integer channel_dialog1 = 1 + (integer)("0x" + llGetSubString((string)llGetOwner(), -8, -1));
integer channel_dialog2 = 2 + (integer)("0x" + llGetSubString((string)llGetOwner(), -8, -1));
llListen(channel_dialog1, "", NULL_KEY, "");
llListen(channel_dialog2, "", NULL_KEY, "");
 
...
...
 
    listen(integer chan, string name, key id, string msg)
    {
        if (chan == channel_dialog2) {
           
            //do stuff
        }
        else if (chan == channel_dialog1) {
 
            // do stuff

But channel_dialog1 and channel_dialog2 are not defined within the listen function, how would I go about doing this?

Link to comment
Share on other sites

You've done it.  At least, you're very close.  Make the two channel variables global and then assign values to them the way that you have, but do it in the state_entry event, where you also need to put the two llListen functions.  That will open your two channels and make the values available in the listen event for your two if tests.  The only improvement I might suggest is to change "0x" to "0xF" so that the resulting channel number is negative. 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3202 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...