Jump to content

Communication among objects in a linkset or region.


Nadee0209
 Share

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

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

Recommended Posts

there is a linkset of two objects

this code goes in first object

default
{
    touch_start(integer total_number)
    {
        llRegionSayTo(llGetKey(), -99, "flame");
    }
}

this goes in another object i m communicating to : i am not sure how to use a listen() so i m getting error in this code

default
{
    state_entry()
    {
        listen( integer -99, string name, key id, string message )    //<----- here is the syntax error
        {
            if(message == "flame")
            {
                llSay(0, "burn");
            }
        }
    }
}

i read the wiki but still unsure how to use listen() properly to make it work

 

 

 


 

 

Link to comment
Share on other sites

That won't quite work as written because llGetKey() will yield the UUID of the object that the script is in.  Your script will be trying to send a message to itself.  That's not what you intended (and, in fact, it's impossible).  You need to use the UUID of the object that you want to send the message to.

It also won't work because your receiving script's listen event isn't written properly. You can't put one event inside another one, so the listen event has to get out of state_entry, where you put it.  In order to listen, the script also needs to know how to listen, which means that you can't trigger a listen event unless you have already opened a channel with a llListen function.  That's what belongs in the state_entry event.  So

default

{
    state_entry()
    {
        llListen(-99,"","","");    // This opens the channel, assigning -99 as the channel number
    }

    listen(integer channel, string name, key id, string message)
    {
        if (message == "flame")
        {
            llSay(0,"burn");
        }
    }
}

I suggest spending a little time with some basic tutorials (like this one: http://wiki.secondlife.com/wiki/Getting_started_with_LSL ) that will get you started with the state/event structure of LSL and introduce some primary functions.  Then start finding your way around the LSL wiki.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

What Rolig said quicker than me.

The only other thing I was going to suggest is that if you're trying to figure out the receiving object's key you could put this line into the state _entry event, just under where Rolig has the llListen line, so it'll tell you what it is when the script starts:

        llOwnerSay ("My key is " + (string) llGetKey ());

You can then copy and paste it from your chat history into the sending object's script, replacing where you've used llGetKey. Don't forget to enclose the key in quote marks.

Edited by KT Kingsley
  • Like 3
Link to comment
Share on other sites

Or just use llRegionSay, which doesn't require the receiver's UUID,  instead of llRegionSayTo.  If you really think that it's necessary to be sure that the sender and listener are only speaking exclusively to each other, then you could tell the receiving script to listen only to objects named, for example, My_Home, with

llListen(-99,"My_Home","","");

 

  • Like 1
Link to comment
Share on other sites

9 hours ago, KT Kingsley said:

What Rolig said quicker than me.

The only other thing I was going to suggest is that if you're trying to figure out the receiving object's key you could put this line into the state _entry event, just under where Rolig has the llListen line, so it'll tell you what it is when the script starts:


        llOwnerSay ("My key is " + (string) llGetKey ());

You can then copy and paste it from your chat history into the sending object's script, replacing where you've used llGetKey. Don't forget to enclose the key in quote marks.

 Thank you KT Kigsley, this is quite a good trick and gonna help me a lot in further learning :)

 

 

Link to comment
Share on other sites

10 hours ago, Rolig Loon said:

That won't quite work as written because llGetKey() will yield the UUID of the object that the script is in.  Your script will be trying to send a message to itself.  That's not what you intended (and, in fact, it's impossible).  You need to use the UUID of the object that you want to send the message to.

It also won't work because your receiving script's listen event isn't written properly. You can't put one event inside another one, so the listen event has to get out of state_entry, where you put it.  In order to listen, the script also needs to know how to listen, which means that you can't trigger a listen event unless you have already opened a channel with a llListen function.  That's what belongs in the state_entry event.  So


default

{
    state_entry()
    {
        llListen(-99,"","","");    // This opens the channel, assigning -99 as the channel number
    }

    listen(integer channel, string name, key id, string message)
    {
        if (message == "flame")
        {
            llSay(0,"burn");
        }
    }
}

I suggest spending a little time with some basic tutorials (like this one: http://wiki.secondlife.com/wiki/Getting_started_with_LSL ) that will get you started with the state/event structure of LSL and introduce some primary functions.  Then start finding your way around the LSL wiki.

Thank you Rolig Loon for such a quick response.

Yes i was doing some very trivial mistakes and now i learned how to initiate that and call it properly.

 

 

10 hours ago, Rolig Loon said:

Or just use llRegionSay, which doesn't require the receiver's UUID,  instead of llRegionSayTo.  If you really think that it's necessary to be sure that the sender and listener are only speaking exclusively to each other, then you could tell the receiving script to listen only to objects named, for example, My_Home, with

llListen(-99,"My_Home","","");

 

And Yes this is exactly what I should have done. I was unnecessarily using llRegionSayTO() instead of llRegionSay(). In my case, the sender and the listener are exclusively communicating with each other. And putting object name in llListen() makes it more accurate

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

2 hours ago, Wulfie Reanimator said:

Since the question specifies "objects in a linkset" and "a linkset of two objects," I assume this is a linkset and not two separate objects?

If that's the case, you shouldn't be using RegionSay, but llMessageLinked and the link_message event.

Can we use llMessageLinked  to communicate among the objects in a linkset?

to me, the Wiki of llMessageLinked  sounds bit ambiguous because the first statement of description says - "The purpose of this function is to allow scripts in the same object to communicate." By this statement i make a note that we cannot communicate to other object script no matter if it is linked object.

the next statement is - "It triggers a link_message event with the same parameters num, str, and id in all scripts in the prim(s) described by link."  I think it means we can communicate to the scripts in other linked objects by passing a LINK_* flag control.

(ref - http://wiki.secondlife.com/wiki/LlMessageLinked)

 

Link to comment
Share on other sites

6 minutes ago, Nadee0209 said:

Can we use llMessageLinked  to communicate among the objects in a linkset?

to me, the Wiki of llMessageLinked  sounds bit ambiguous because the first statement of description says - "The purpose of this function is to allow scripts in the same object to communicate." By this statement i make a note that we cannot communicate to other object script no matter if it is linked object.

I think you're getting confused about "object" here. Think of "Object" as a linked set of children. Then a link message from a script in any of the child prims is available for any other child prim that has a script to receive, or in fact another script in the same child prim that sends it. The link flag controls then can be LINK_ALL_OTHERS to broadcast the link message to any scripts in the rest of the linkset. Other flags allow targetting specific children, or even the sending child so that other scripts in it get the lessage but no other children.

Link to comment
Share on other sites

14 minutes ago, Nadee0209 said:

Can we use llMessageLinked  to communicate among the objects in a linkset?

to me, the Wiki of llMessageLinked  sounds bit ambiguous because the first statement of description says - "The purpose of this function is to allow scripts in the same object to communicate." By this statement i make a note that we cannot communicate to other object script no matter if it is linked object.

the next statement is - "It triggers a link_message event with the same parameters num, str, and id in all scripts in the prim(s) described by link."  I think it means we can communicate to the scripts in other linked objects by passing a LINK_* flag control.

(ref - http://wiki.secondlife.com/wiki/LlMessageLinked)

llMessageLinked takes a parameter link, which determines which link(s) in a linkset will receive the message/event.

5 minutes ago, Profaitchikenz Haiku said:

The link flag controls then can be LINK_ALL_OTHERS to broadcast the link message to any scripts in the rest of the linkset.

LINK_ALL_OTHERS means all links except the one this script is in. It's not the same as LINK_SET (all links) or LINK_ALL_CHILDREN (all links except root). I point this out because "the rest of the linkset" depends on a lot of things.

Edited by Wulfie Reanimator
Link to comment
Share on other sites

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