Jump to content

If prim is a sculpt, do X, else do Y


Asha Arida
 Share

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

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

Recommended Posts

I seem to be hung up on this if statement. I need to do the following:

if(prim at link# is a sculpt)

do X

else

do Y

 

Essentially I have a script that says "If the color of face a on prim b is color c, change it to color d". However, since sculpts (as far as I can tell) only have 1 face, I need to change the syntax of the command to include ALL_SIDES. My loop looks like this:

        while(primNum > 0)
        {
            integer faceNum = (llGetLinkNumberOfSides(primNum));
            while(faceNum >= 0)
            {
                compareColor = llGetLinkPrimitiveParams(primNum,[PRIM_COLOR, faceNum]);
                parsedCompareColor = parse(compareColor);

                primType = llGetLinkPrimitiveParams(primNum,[PRIM_TYPE]);
                parsedType = parse(primType);

                if(parsedBaseColor == parsedCompareColor)
                {
                    
                    if(parsedType == "7") //If type = sculpt
                    {

                        llSetLinkPrimitiveParamsFast(primNum, [PRIM_COLOR, ALL_SIDES, (vector)parsedNewColor, alpha]);
                    }
                    else
                        llSetLinkPrimitiveParamsFast(primNum, [PRIM_COLOR, faceNum, (vector)parsedNewColor, alpha]);

                }
                faceNum--;
                
            }
            primNum--;
        }

 The other prims change fine but if it hits a sculpt prim, it does nothing. As far as I can tell, it gets into the loop but setprimparams doesn't seem to want to change.

Link to comment
Share on other sites

Without seeing the parse() function, it's going to be hard to troubleshoot.  The issue lookes to be the if statement:

 

if(parsedType == "7") ...

 

I'd check to see what parse(primType) is returning, and going from there.

 

If parsedType has been coerced into a string type, it should work.  If parsedType is an integer type, it's always going to fail.

So if parsedType is an integer, just change the if statement above to be:

if((string)parsedType == "7") ...

but if parsedType is a string, I'd look to make sure parse() isn't adding whitespace or such somewhere in the string.

 

Link to comment
Share on other sites

Oops! the parse function was so simple I forgot to add it.

string parse(list in){    string out = llList2String(in, 0);    return out;    }

 All it does is remove the alpha from the color vector that llGetPrimParams returns. Anyway the problem is parse() works fine for prims that are not sculpts. But as soon as it hits a sculpt, the llSetPrimParams function doesn't work. It doesn't crash, but the function doesn't appear to do anything.

Link to comment
Share on other sites

One problem is that you're starting faceNum at llGetLinkNumberOfSides(), but faces are zero-indexed, so you really mean to start it at one less than that.

But I don't think that's what's preventing it working (eventually) for a sculpt. I'm wondering if parsedBaseColor is something to worry about.

[ETA: Incidentally, a special case for sculpts shouldn't be necessary. It only has one face, but it can be handled the same as multi-faced prims, too. In fact, with Mesh, you'd really want to handle each face separately and (I think) it will match PRIM_TYPE_SCULPT.]

Link to comment
Share on other sites

parsedBaseColor is set outside the loop before it runs. Thanks for the tip though; I updated faceNum but as you suspect it's still seeming to ignore sculpts. I think my problem is in this block:

 

                    if(parsedType == "7") //If type = sculpt                    {                        llSetLinkPrimitiveParamsFast(primNum, [PRIM_COLOR, ALL_SIDES, (vector)parsedNewColor, alpha]);                    }

 But I really don't know

Link to comment
Share on other sites

The behavior of the llList2X() functions are not guaranteed to work correctly if the type of the list entry does not match the result type X.  Try changing parse() to:

 

integer parseint(list in){    return llList2Integer(in, 0);}

 And call this one for the parsing of the PRIM_TYPE, and change the if test to be (primType == 7).

 

I don't think it is a problem with your call to llSetLinkPrimitiveParams() but with the comparison in the if block.  Quick test, put an llOwnerSay inside the if(primType == "7")... block.

 

Link to comment
Share on other sites

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