Jump to content

Help needed, trying to target a prim in linkset


MSTRPLN
 Share

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

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

Recommended Posts

Hello, I've made a script that worked fine untill i linked this to the rest of my building.

I'm making a house that could be used as a store, therefore it has a billboard on the front tha i wanted to hide when clicked on. I've managed to do this, and also hide the 2 projector lights inside tht i made (billboard was the root) But now that i've linked this to the rest of my house the house becomes the root and "LINK_ALL_CHILDREN" affects everythig  now not just those 2 lights annymore.

 

How can i change this script so that when clicked on prim A, prim B & C will be affected, if not i could put the same script in the 2 lights but then i would have to know how to run those 2 whenever a different prim is clicked.

 

A image of the set up:



 

Script so far:

/*****************************
*   Billboard Light Toggle   *
*      Script by MSTRPLN     *
******************************/
integer flip;

default
{
    on_rez(integer param)
     {
         llResetScript();
     }
     
    touch_start(integer total_number)
    {
        // Flips normals to hide root object
        if (flip) flip = 0; else flip = 1;
        llSetLinkAlpha(llDetectedLinkNumber(0),flip,ALL_SIDES);
        
        
        // This affects 2 light prims inside the root
        if (flip == TRUE) { // Light is ON
        llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN,[PRIM_POINT_LIGHT, TRUE, <0.965, 0.957, 0.396>, 1.0, 5.0, 0.5]);
        
        } else if (flip == FALSE) { // Light is OFF
        llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN,[PRIM_POINT_LIGHT, FALSE, <0.965, 0.957, 0.396>, 1.0, 5.0, 0.5]);
        }
     }
}

 

Instead of ResetScript, is it possible that this script remembers the toggle? i can imagine it would be quite annoying having to hide it every single time 

 

Thanks in advance

Link to comment
Share on other sites

read up on: http://wiki.secondlife.com/wiki/PRIM_LINK_TARGET

PRIM_LINK_TARGET allows us to work with specific prims in the linkset

we can also combine multiple prim targets in the same llSetLinkPrimitiveParamsFast call

using your code as a base then it goes something like: (note that i simplified the flip/toggle code)

 

integer PRIM_A = 3; // linkset num of A prim. Whichever num it may beinteger PRIM_B = 2; // linkset num of B prim. Whichever num it may beinteger flip;  // is off to startdefault{       // assumes that the prims are visually set in the off position     // before the script is reset    touch_start(integer total_number)    {        flip = !flip;   // toggle between off and on         // LINK_THIS to hide/show the prim this script is in         // PRIM_A and PRIM_B affects 2 light prims in the linkset        llSetLinkPrimitiveParamsFast           (           LINK_THIS, [ PRIM_COLOR, ALL_SIDES, <1.0,1.0,1.0>, (float)(!flip),           PRIM_LINK_TARGET, PRIM_A, PRIM_POINT_LIGHT, flip, <0.965, 0.957, 0.396>, 1.0, 5.0, 0.5,           PRIM_LINK_TARGET, PRIM_B, PRIM_POINT_LIGHT, flip, <0.965, 0.957, 0.396>, 1.0, 5.0, 0.5 ]        );     }}

 

Link to comment
Share on other sites

Thank you, i found out that prim a& b were 8 & 9 in the linkset aso i tried "PRIM_LINK_TARGET=8" but that didnt work, i'll try this and figure it out thank you

 

edit: didnt seem to work properly, i'll have to digg a little further

Link to comment
Share on other sites

That's not the way PRIM_LINK_TARGET works.  PRIM_LINK_TARGET is a LSL constant with the value 34.  You don't try to change that value by setting it equal to something else.  It is a flag in llSetLinkPrimitiveParams that tells the server that the code immediately following is targeted to a specific child prim.  Look at the example at http://wiki.secondlife.com/wiki/PRIM_LINK_TARGET

Link to comment
Share on other sites

You target the links by number, just as always.  PRIM_LINK_TARGET just lets you daisy chain several commands to different links in the same function call to llSetLinkPrimitiveParams. For example ...

 

integer gChildA;integer gChildB;default{    state_entry()    {        integer i;        while (i < llGetNumberOfPrims() )        {            if ( llGetLinkName(i) == "link a")            {                gChildA = i;            }            else if ( llGetLinkName(i) == "link b")            {                gChildB = i;            }            ++i;        }    }    touch_start(integer num),    {        llSetLinkPrimitiveParams(LINK_SET,[PRIM_LINK_TARGET,gChildA,PRIM_COLOR,ALL_SIDES,<1,1,1>,1.0,PRIM_LINK_TARGET,gChildB,PRIM_POS_LOCAL,<2.0,1.0,0.0>]);    }}

So, you've identified the links by number in state_entry and then you are using the link numbers (gChildA and gChildB) to set the color of the link named "prim a" and the local position of the link named "link b", using a single call to llSetLinkPrimitiveParams.  The PRIM_LINK_TARGET parameter tells the server that it's supposed to target the numbered link that follows immediately. 

 

Link to comment
Share on other sites

there is a lot to read on the wiki about this

look at the code examples like Rolig suggests and test them out. Play with them using the wiki as a reference guide. And after a bit then you will work out what you need to do to make your stuff go how you want

and what the LSL syntax is when working with multiple prims. Parameters for SetParams... are passed as a list. So the LSL syntax equivalent of PRIM_LINK_TARGET=8 is:

[ PRIM_LINK_TARGET, 8 , ... parameters for prim 8 ..., PRIM_LINK_TARGET, 9, ... parameters for prim 9 ...  ]

 

eta: took out some stuff not needed

 

Link to comment
Share on other sites

I've got it to work with combining Rolig Loon's example with mine

Script:

/******************************   Billboard Light Toggle   **      Script by MSTRPLN     *******************************/integer gChildA;integer gChildB;integer flip;default{    on_rez(integer param)     {         llResetScript();     }    state_entry()    {        integer i;        while (i < llGetNumberOfPrims() )        {            if ( llGetLinkName(i) == "AdLight1")            {                gChildA = i;            }            else if ( llGetLinkName(i) == "AdLight2")            {                gChildB = i;            }            ++i;        }    }         touch_start(integer total_number)    {        // Flips normals to hide object        if (flip) flip = 0; else flip = 1;        llSetLinkAlpha(llDetectedLinkNumber(0),flip,ALL_SIDES);                        if (flip == TRUE) { // Light is ON        llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_LINK_TARGET,gChildA,PRIM_POINT_LIGHT, TRUE, <0.965, 0.957, 0.396>, 1.0, 5.0, 0.5,PRIM_LINK_TARGET,gChildB,PRIM_POINT_LIGHT, TRUE, <0.965, 0.957, 0.396>, 1.0, 5.0, 0.5]);                } else if (flip == FALSE) { // Light is OFF        llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_LINK_TARGET,gChildA,PRIM_POINT_LIGHT, FALSE, <0.965, 0.957, 0.396>, 1.0, 5.0, 0.5,PRIM_LINK_TARGET,gChildB,PRIM_POINT_LIGHT, FALSE, <0.965, 0.957, 0.396>, 1.0, 5.0, 0.5]);        }     }}

On state:


Off State:


 

Thanks for the help guys :) i wasnt sure how to implement the PRIM_LINK_TARGET but now i do :)

Link to comment
Share on other sites

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