Jump to content

Making a link member touch other link members


Aviewer Alpha
 Share

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

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

Recommended Posts

I'm new so I'm sorry if this is a silly question, I may be missing a simple command that I have yet to find yet....

I have a few modify items that I'd like to link together and when one is touched all the rest of the links get passed a touch as well... I see a way to pass a touch to the root link but I don't see a way to have everything get a touch. One solution I read would be to have a script that sends a message and a receiving script to perform the action on every member of the link but ultimately I would need that object to touch itself using that method and I haven't found a way.

 

Any help would be apricated thanks!

  • Thanks 1
Link to comment
Share on other sites

If you do use llMessageLinked() and send the message to "this" or "all links", my experience is that the "sender" also gets the message.

This can be annoying if you forget to check in the link_message() event and don't expect it. I deal with this by sending a string in the "key id" parameter, then scripts ignore any value of "id" they don't expect. (You just have to cast/convert "id" to a string before checking:

 

if ( (string)id != "my value" )

   return;

Anyway, hopefully someone else will reply and confirm or refute my answer!

Link to comment
Share on other sites

The best way to approach this normally is to have a script in the root prim with a touch_start event, combined with llDetectedLinkNumber(0)

Example:

default
{
	touch_start(integer tot_num)
    {
		llSay(0, "Touched link: " + (string)llDetectedLinkNumber(0));
      	//After this point, do whatever. Maybe use an IF statement depending on what link was touched.
    }
}

 

Link to comment
Share on other sites

Yeah I get how to handle touch detection, the problem is that I want the touch action to be ran against every member of the link... In this case we're talking about several window blinds made by another created. I'm hoping to link them together and have them work "in unison" when a single member of the link is touched. To do that I need that touch action to be passed to and performed on every member of the link set.

Link to comment
Share on other sites

45 minutes ago, Love Zhaoying said:

If you do use llMessageLinked() and send the message to "this" or "all links", my experience is that the "sender" also gets the message.

Yes, a script can hear its own llMessageLinked if directed to itself. The wiki page for the function explicitly warns about that. There are a few additional special link constants that are useful for scenarios like that. LINK_ALL_OTHERS would omit the prim containing the current script that issued the llMessageLinked

Flag Description
LINK_ROOT 1 sends to the root prim in a multi-prim linked set[1]
LINK_SET -1 sends to all prims
LINK_ALL_OTHERS -2 sends to all other prims
LINK_ALL_CHILDREN -3 sends to all children, (everything but the root)
LINK_THIS -4 sends to the prim the script is in

 

As for the original question, no it's to possible to trigger touch events in other linked prims like that.

If you have modify access to the scripts, it may be possible to edit them to respond to linked messages instead of touchs.

Ideally, I would consider replacing the scripts with a single one in the root that can perform the action on all link targets without the need for scripts in the links themselves.

 

Edited by Fenix Eldritch
typos, additional info
Link to comment
Share on other sites

5 minutes ago, Love Zhaoying said:

That only controls if, when a link is touched, if that touch event will be passed to the root of the linkset (the default behaviour), or to not pass the touch event. It won't fire a touch event for any other link than the link root.

  • Thanks 1
Link to comment
Share on other sites

5 hours ago, Aviewer Grumpypants said:

a receiving script to perform the action on every member of the link

I think you might be misunderstanding that since a long time ago, scripts in one link can now perform basically any action on any other link in the same object

https://wiki.secondlife.com/wiki/LlSetPrimitiveParams#llSetLinkPrimitiveParamsFast

Link to comment
Share on other sites

Correct. However, there are LSL functions you can use which can do things to other prims in the linkset when clicking on any prim. The suggestion about using llSetLinkPrimitiveParamsFast is one way in which you can trigger an action that can affect multiple links on the linkset.

For example, rez three or more cubes and link them together. Drop this script into the root. Clicking on any part of the object will pass the touch event to the root (default behavior). The root's script as shown below will react to the touch event, but it can modify all other links in the linkset with ease.

integer toggle = FALSE;

default
{
    touch_start(integer total_number)
    {
        
        if(toggle = !toggle)
        {
            llSetLinkPrimitiveParamsFast(LINK_ALL_OTHERS, [PRIM_SLICE, <0.95, 1.0, 0.0>]);
        }
        else
        {
            llSetLinkPrimitiveParamsFast(LINK_ALL_OTHERS, [PRIM_SLICE, <0.0, 1.0, 0.0>]);
        }
    }
}

 

Edited by Fenix Eldritch
Link to comment
Share on other sites

On 8/23/2022 at 11:56 PM, Aviewer Grumpypants said:

In this case we're talking about several window blinds made by another created. I'm hoping to link them together and have them work "in unison" when a single member of the link is touched.

Are these window blinds already scripted by their creator? Is the reason you're trying to pass touch events because those already existing scripts have touch events, which you can't change?

Or are you scripting the blinds yourself as well?

  • Like 1
Link to comment
Share on other sites

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