Jump to content

Please help totally stuck with listeners


Cat Tamatzui
 Share

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

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

Recommended Posts

Hi I am totally lost with listeners, I have 2 huds i need to be able to talk to 2 different attached objects but they both change the texture on the same attached objects, how without specifying a separate channel for both huds do i have it so they will talk to the different objects, how do i get each object to listen for a different name I thought just changing this listenHandle = llListen(chan, "test1", NULL_KEY, ""); to test1 and test2 would work but how do i send that information to the object, i have searched and looked at scripts and read the wiki over and over and im just totally stuck, any help would be much appreciated.

I am trying to make it so I only have to change the name sent and the uuids, i just cant figure out how to send the name to the receiver, thank you :)

here is the hud

integer i;
integer chan;
string name = "test1";

string face1 = "30e14cf8-7faa-06da-1433-f6afde2c336a";
string face2 = "39376811-2ccf-3296-5064-3d1bc63bd268";

default
{
  state_entry()
  {
      chan =  ( -1 * (integer)("0x"+llGetSubString((string)llGetOwner(),-5,-1))-50007 );

  }
  
 on_rez(integer start_param)
  {
    llResetScript();
  }
  
    touch_start(integer num_detected)
    {
        integer face = llDetectedTouchFace(0);
 
        if (face == 1){
            llSay(chan, face1);
        }
       else if (face == 2){
           llSay(chan, face2);
}

}
}

 

and here is the receiver

 

integer chan;
integer listenHandle;

default
{
  state_entry()
  {
      chan =  ( -1 * (integer)("0x"+llGetSubString((string)llGetOwner(),-5,-1))-50007 );
     listenHandle = llListen(chan, "test1", NULL_KEY, "");
  }
  listen(integer chan, string name, key id, string msg)
   {        
       if(llGetOwnerKey(id)==llGetOwner())
      {
           llSetTexture(llGetSubString(msg,0,-1),ALL_SIDES);
            {
            }
        }
    }
}

 

Link to comment
Share on other sites

In your specific case if the names aren't going to change, the sender has to know those names and it uses the name with an appended = in front of whatever message it wants to send. So it might say "Object1=changeYourFace"

The receiver uses it's own name when it receives messages and ignores any message that does not begin with it's own name, and takes the remainder of the message after the = otherwise.

 

For a general case where names might change or objects get re-rezzed consider this approach:

In the receiver, have a global string called ListenFor, initialised to ""

In state_entry, if listenFor is ""

* open a listener on the required channel but specify "" in the name parameter

* send a message to the sender (or on whatever channel is going to be used)  "identity?"

 

If the sender gets a message "identity?" it replies to the id or name it heard with a string "identity=" + requiredName

In the sender, if it receives a message beginning "identity="

* it takes the remainder of the message and assigns it to listenFor

* closes the current listen

* re-opens the listen with listenFor in the name parameter

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

you could also drop messages where llGetOwner() != llGetOwnerKey(sender)

(to clarify)

Since, I understand that this is a hud for some item, I assume there will never be a case where a valid message will be sent by a hud owned by someone who isn't also the owner of the receiver?

Edited by Kyrah Abattoir
  • Like 1
Link to comment
Share on other sites

You send a message with a separator and convert it to a list.

For example: llSay(channel, "123#30e14cf8-7faa-06da-1433-f6afde2c336a");

On the receiving prim:
list my_list = llParseString2List(msg,["#"],[]);
string var1 = llList2String(my_list,0);
string var2 = llList2String(my_list,1);

if(var1 == "123"){
      llSetTexture(var2,ALL_SIDES);
}

Link to comment
Share on other sites

I didn't do my due diligence and read through the script. but I thought I'd mention that llRegionSayTo() is a rather useful function if you want / need to use the same channel for communication between one sender and multiple listeners, and it can help prevent cross traffic regardless.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1122 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...