Jump to content

Object name responds to llSetLinkPrimitiveParamsFast rules


Rhemah
 Share

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

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

Recommended Posts

i want to create rules in llSetPrimitiveParamsFast wherein the child prim with the same Object name respond to it.

 its like making:

llSetLinkPrimitiveParamsFast(integer link, list rules)

into something like:

llSetLinkPrimitiveParamsFast( integer(Objectname), list rules );

Link to comment
Share on other sites

You would have to get the name and number of each prim in the link set and then have a set of int variables which are the names of the prims and then initialize them to the link number. I cant think of an efficient way to do it, maybe someone knows a trick.

Here is how you can get the names/numbers of the prims in a link set: http://wiki.secondlife.com/wiki/LlGetLinkName

Link to comment
Share on other sites

list names = ["childprim1","childprim2","childprim3","Root"];
string this = "Root";
default
{
state_entry()
{
integer index = llListFindList(names,[this]);
llSetLinkPrimitiveParamsFast(index, [PRIM_GLOW, ALL_SIDES,0.5]);
}
}

It seems like only the childprim2 is glowing, i tried removing the Root in the list but the result it made all linkprim glows... umm im not sure if i did it right, a little help pls..:matte-motes-crying:

Link to comment
Share on other sites

You need to loop through the linkset, either by storing linknumbers with the name "Root" in a list, or just loop through the set each time. The first method might be preferable in a large linkset with only a few prims to change. With smaller linksets I would just do it like this:

default{    state_entry()    {        string sName = "Root";        integer iPrims = llGetNumberOfPrims();        while(iPrims)        {            if (sName == llGetLinkName(iPrims))            {                llSetLinkPrimitiveParamsFast(iPrims, [PRIM_GLOW, ALL_SIDES,0.5]);            }            --iPrims;        }    }}

 

  • Like 1
Link to comment
Share on other sites

what arton and Ohijiro mention is what I neglect to mention in my first. Have to construct a list/lookup method

example to demo the principle:

 

// in linkset then index starts at 1 so list objsByName can begin// with a dummy element at index 0// or can start empty and then add 1 to the index each time//// for this example then we go with a dummy to avoid the add// instruction on each find (space for time tradeoff)list objsByName = [""]; default{    state_entry()    {        // build the objsByName list        integer n = llGetNumberOfPrims();        integer i;         // <=n and not <n bc linkset is 1-based index        for (i = 1; i <= n; i++)            objsByName += llGetLinkName(i);    }    touch_start(integer total_number)    {        // test        // 4 linked objects named Object1..Object4        string this = "Object1";        integer i = llListFindList(objsByName, [this]);        llSetLinkPrimitiveParamsFast(i, [PRIM_GLOW, ALL_SIDES,0.5]);         this = "Object4";        i = llListFindList(objsByName, [this]);        llSetLinkPrimitiveParamsFast(i, [PRIM_GLOW, ALL_SIDES,0.5]);                llSleep(3.0);        llSetLinkPrimitiveParamsFast(i, [PRIM_GLOW, ALL_SIDES,0.0]);                
this = "Object3"; i = llListFindList(objsByName, [this]); llSetLinkPrimitiveParamsFast(i, [PRIM_GLOW, ALL_SIDES,0.5]); }}

 

by itself the above is not all that useful. Like arton mentions tho stuff can become more problematic maintenance-wise when start applying to large linksets. So in the more complex case can think about using a translation matrix

+

example next:

is functionally the same as above. Except that is now moving more toward a data dictionary approach to coding. bc matrix.

meaning that for each prim of actionable relevance (not all prims might be actionably relevant) in the linkset then can just add its name and rules into the matrix. And the execute/logic codes will continue to work without change

which can be useful when devving the product and/or when the product is linkset dynamic at runtime. Like adding/removing/linking/unlinking and changing the rules based on linkset changes

 

list objNames = [  "Object1",   "Object2",   "Object3",   "Object4"];list objGlows = [  0.5, // Object1  0.4, // Object2  0.3, // Object3  0.2  // Object4];  list objLinks = []; default{    state_entry()    {        // build the objLinks list        list m = [""];        integer n = llGetNumberOfPrims();        integer i;        for (i = 1; i <= n; i++)            m += llGetLinkName(i);        n = llGetListLength(objNames);        for (i = 0; i < n; i++)            objLinks += [llListFindList(m, [llList2String(objNames, i)])];    }    touch_start(integer total_number)    {        // test        // 4 linked objects named Object1..Object4                string this = "Object3";        integer k = llListFindList(objNames, [this]);         float   g = llList2Float(objGlows, k);        integer i = llList2Integer(objLinks, k);        llSetLinkPrimitiveParamsFast(i, [PRIM_GLOW, ALL_SIDES, g]);         this = "Object4";        k = llListFindList(objNames, [this]);        g = llList2Float(objGlows, k);        i = llList2Integer(objLinks, k);        llSetLinkPrimitiveParamsFast(i, [PRIM_GLOW, ALL_SIDES, g]);                llSleep(3.0);        llSetLinkPrimitiveParamsFast(i, [PRIM_GLOW, ALL_SIDES, 0.0]);                
this = "Object2"; k = llListFindList(objNames, [this]); g = llList2Float(objGlows, k); i = llList2Integer(objLinks, k); llSetLinkPrimitiveParamsFast(i, [PRIM_GLOW, ALL_SIDES, g]); }}

 +

just about data dictionary approach

when start adding lots of different rules into the matrix then it becomes more and more useful

also in the 2nd example can see that Object1 is not actionable in the codes so can remove it from the matrix (objNames and objGlows) and the executable codes will still work without changes

Link to comment
Share on other sites

list names = ["null"];  // set the zero position in the list to null

default

{

state_entry()

{ integer x;

integer len = llGetNumberOfPrims();

for(x=1; x<len; ++x) // x = 1 .... root prim is 1 in a linkset

{ names += llGetLinkName(x); // add all names in the linkset to your list , the index of the name is the link number

}

 

}

touch_start(integer total_number) // shown in touch event, can be anywhere tho...

{ string linkNAME = "Ob 2"; // set your target here or use listen, sensor , etc to set it...

integer index = llListFindList(names, [linkNAME]); // if your name is mis-spelled, the index will be -1 .. and all links will glow

if(index == -1)

{ llOwnerSay("Bad link name");

return;

}

 

llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_GLOW, ALL_SIDES,0.0]);

llSetLinkPrimitiveParamsFast(index, [PRIM_GLOW, ALL_SIDES,0.5]);

}

}

 

 

Link to comment
Share on other sites

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