Jump to content

Filter functions by prim description?


Jaysunai Hurricane
 Share

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

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

Recommended Posts

Hello, I'm looking for help on if it's possible to"filter" something with prim names or prim description.

I have an object I'm working on that has multiple "modes", and in each mode, I want some prims to rez, others to hide, others to cut or resize, etc. The object isn't quite done yet, and we may need to edit it to add or take off prims later.

What my idea was, instead of listing over 40 named integers for each prim to get it to behave how I want, I was thinking of grouping them with prim description. I'm doing this by having, say, all that show up only in Mode 2 share a common prim description, the ones that only show in Mode 1 have the same description, etc.

Is there a way to call up prim description so that it only applies alpha, color, size, etc. changes on only prims with that description?

Thanks.

Link to comment
Share on other sites

primset can filter by name or description.   Drop it in the root prim and chat to it on channel 884.

The part in the square brackets is a list of names or prim numbers.

          [foo,bar] 21, 1, 3, 0.2, 1.2, 2.5, 7.5, <0,0,0>

would set the flexi params of the prims in the linkset with a name or description of "foo" or "bar":

(flexible, true,  softness 3, gravity 0.2, friction 1.2, wind 2.5, tension 7.5, force <0,0,0>)

The arguments after the square brackets are a list to pass to llSetLinkPrimitiveParamsFast().

You could use  primset as-is or modify it to do what you need.

 

Link to comment
Share on other sites

Absolutely!

 

I used a function like this:

list GetPrimsByNameString(string str){    integer i;    listofprims = [];    for(i=1; i <= llGetNumberOfPrims(); ++i)    {        if(llSubStringIndex(llGetLinkName(i), str) != -1)        {            listofprims += [ i ];        }    }    return listofprims;}

 So if the pattern str is found anywhere in the name of the prim in the linkset, that prim index is added to the list to be returned.  Call it whenever you need a list of whatever prims you need.  Write other functions that do a specific action on a list of prims....say, setting color and alpha, like so:

SetLinkedColorAndAlpha(list primlist, vector color, float alpha){    integer i;    if(llGetListLength(primlist)==0) return;    for(i=0; i < llGetListLength(primlist); ++i)    {        llSetLinkAlpha(llList2Integer(primlist,i), alpha, ALL_SIDES);        llSetLinkColor(llList2Integer(primlist,i), color, ALL_SIDES);    }}

 Now, in your code you can simply call them.....

....    // Set all prims with "foo" in their name to 50% transparent black.    SetLinkedColorAndAlpha(GetPrimsByNameString("foo"), <0.0,0.0,0.0>, 0.5);...

 Doing it with the description field is a little more difficult, but not much.  Just use llGetLinkPrimitiveParams() to get the description fields to test in the first function, instead of using llGetLinkName().

 

Link to comment
Share on other sites

Just a couple of notes/additions:

 

To set the 'GetPrimsByNameString' function to work by prefixes or suffixes only requires changing the -1 in the test.  For prefixes, compare with 0 instead.  For suffixes, compare to (-llStringLength(str)).

 

You could even pass a parameter into the function to specify that.  Say,

list GetPrimsByNameString(string str, int position) { ... }

and pass in either 0, -1, or -llStringLength(str) for position to tell it (and possibly predefine int values for the common ones.)

 

You can also save the lists returned (assuming the linkset won't be changing while running) so you don't have to run the loop each time.  Just set a global list variable for each set  you need to keep and do it during the state_entry() of the default state.

 

Link to comment
Share on other sites

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