Jump to content

Question llPassTouches


Wandering Soulstar
 Share

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

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

Recommended Posts

Hi All,

Have a question in regards to passing touches from a child to root. Scenario:

Two unlinked prims .. each with the same script in them that does something in the touch_end event. If they are linked though I only want the script in the root to react. Now I know I could do it this way:

    changed(integer change)
    {
        if (change && CHANGED_LINK)
        {
            if (llGetLinkNumber() > 1){llPassTouches(PASS_ALWAYS);}
            else (llPassTouches(PASS_NEVER);}
        }
    }
    touch_end(integer total_number)
    {
        if (llGetLinkNumber() < 2)
        {
            //do stuff
        }
    }

what I am wondering is if there is a way to simply do this in the touch_end, so that the changed event is not constantly firing .. something like:

    touch_end(integer total_number)
    {
        integer link = llGetLinkNumber();
        
        if (link > 1)
        {
            llPassTouches(PASS_ALWAYS);;
        }
        else
        {
            llPassTouches(PASS_NEVER);
            //do stuff
        }
    }

Does anyone know if this would work? Can't get in-world for the next few days to test myself.

 

Thanks!

Wanda

Link to comment
Share on other sites

llPassTouches is a bit of a legacy feature, back when you needed scripts to live inside child objects if you wanted to affect them in any ways.

You'd be much better off running a single script from the root prim and using llDetected* functions to determinate what was clicked and which function to trigger.

  • Like 1
Link to comment
Share on other sites

47 minutes ago, Kyrah Abattoir said:

You'd be much better off running a single script from the root prim and using llDetected* functions to determinate what was clicked and which function to trigger.

I agree. I wouldn't have thought of llPassTouches at all.  I would simply have added a conditional test

if ( llDetectedLinkNumber(0) == LINK_THIS )
{
    //Do something
}

 

  • Like 1
Link to comment
Share on other sites

Sorry but you misunderstood the scenario (bold emphasis added)

Quote

Two unlinked prims .. each with the same script in them that does something in the touch_end event. If they are linked though I only want the script in the root to react. Now I know I could do it this way:

A simple description (script quite obviously does a lot more) .. when the prim is clicked the script changes the colour of the prim. but if I link the prims, and click on the child, I do not want the child to change the colour (execute the code in touch_end) .. I want the root to do it. 

@Rolig Loon just ignoring the click of the child would not fire the event in the root, which is what I want to do

@Kyrah Abattoir there is no constant root prim .. this is a build tool script that goes into the prims created for the build (of a house for example). As we build they are unlinked, but will begin linking them up, with the tool script remaining in the linked child prims until the build is done.. and thus the need for the functionality

Edited by Wandering Soulstar
Link to comment
Share on other sites

49 minutes ago, Wandering Soulstar said:

A simple description (script quite obviously does a lot more) .. when the prim is clicked the script changes the colour of the prim. but if I link the prims, and click on the child, I do not what the child to change the colour (execute the code in touch_end) .. I want the root to do it. 

Would this do it?  

	touch_start(integer total_number)
	{
		integer n = llDetectedLinkNumber();
		if(!n){//unlinked
			//do stuff to this prim only
		}
		else if (LINK_ROOT == n){
			//do stuff to link set
		}
	}

I see from the wiki that -- and I hadn't realised this -- the default behaviour for touch_* events has changed from the last time I looked (years ago), so that the default is now PASS_ALWAYS -- that is, a child prim containing a  touch* event will always pass the touch to the root prim unless told not to.

Edited by Innula Zenovka
  • Like 3
Link to comment
Share on other sites

@Innula Zenovka  Nope that would not work in the scenario .. I do not want the script to do anything with the linkset .. I want it to act in the prim that was clicked, and if a linkset a click anywhere in the linkset needs to throw the touch-event in the root, so that the script in the root is the one acting (there is a lot going on in the actual code)

Looking at it again with fresh eyes I figured out how to get the behaviour I wanted .. and it was staring me in the face:

    state_entry()
    {
        llPassTouches(PASS_ALWAYS);
    }

    touch_end(integer total_number)
    {
        //only act if unlinked or the root
        if (llGetLinkNumber() < 2)
        {
            //do stuff
        }
    }

Setting this to PASS_ALWAYS should work fine. If the prim is unlinked, there is no one else to receive the touch .. so no big deal, and if it is linked and the root .. well, the pass of the ouch is always to the root, so it would not pass to itself ... problem solved 🙂

  • Like 1
Link to comment
Share on other sites

@Innula Zenovka  I Missed your comment under the code window .. I had read over the Wiki, but to be honest misunderstood that part .. but that raises an issue that I'd like to test in-world because it does not ring correctly, and if it has been implemented as such would have thought that it could have broken tonnes of script systems out there.

  • Previous default behavior - click on a child prim with a script containing a touch event handles the touch, and the event goes no further
  • New(?) default behavior - click on a child prim with a script containing a touch event executes the touch AND the touch goes to the root prim as well if it has a touch event.

So if  I had a panel with a few buttons and wanted something to happen when I clicked the buttons and something else to happen when I clicked the panel .. in the change this would have broken as I'd get the action in the button click and the panel when I clicked a button.

So if this is the case .. then correct, only need to check if the clicked prim is unlinked or the root and away we go .. no need for llPassTouches ... though will have to remember this default behavior going forward <sigh>

  • Like 1
Link to comment
Share on other sites

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