Don't click here unless you want to be banned.

LSL Wiki : llSetPrimitiveParams

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
llSetPrimitiveParams(list rule)

This function changes any number of properties (or "parameters") of a prim in one operation. The parameter is a list of changes. (Don't confuse prim parameters with function parameters.)

The list is parsed and executed one element at a time.

It takes a list as an argument, much as llParticleSystem does. The list always starts with a constant determining the type of change, followed by the parameters that are required by that constant, and then more constant+parameters may follow. For example:

llSetPrimitiveParams([
    PRIM_SIZE, <1, 1, 1>,  
    PRIM_COLOR, ALL_SIDES, <1, 0, 0>,1.0
   ]); //sets the size of the prim to 1x1x1, and then the color of the prim to red

There are many constants that can be used. See the following tables.

Notes
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, 
     <0, 0, 0>, 1.0, PRIM_COLOR, 0, <0, 1, 0>, 1.0]);
...will turn all sides except face 0 black (<0, 0, 0>); face 0 will turn green (<0, 1, 0>).
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <0, 0, 0>, 1.0,PRIM_PHANTOM, TRUE]);
...will turn all sides black (<0, 0, 0>); and set the object phantom

Rules (whenever the "Parameter(s)" column references a PRIM_xxx constant, it can be found in the tables below this one):
Constant Name Description
Alternative
Parameter(s) Example Rule Value
PRIM_BUMP_SHINY Sets bumpmapping and shininess of a face integer face, PRIM_SHINY_xxx, PRIM_BUMP_xxx [PRIM_BUMP_SHINY, 2, PRIM_SHINY_LOW, PRIM_BUMP_GRAVEL] 19
PRIM_COLOR Sets color and alpha of a face
llSetColor, llSetAlpha
integer face, vector color, float alpha [PRIM_COLOR, 1, <1, 0, 0>, 0.75] 18
PRIM_FLEXIBLE Toggles flexible property and attributes: softness, gravity, drag (friction), wind, tension, and force. boolean TRUE/FALSE, integer softness, float gravity, float friction, float wind, float tension, vector force [PRIM_FLEXIBLE, TRUE, 2, 0.3, 2.0, 0.0, 1.0, <0, 0, 0>] 21
PRIM_FULLBRIGHT Sets full bright of a face on or off. integer face, boolean on
on = TRUE/FALSE
[PRIM_FULLBRIGHT, ALL_SIDES, TRUE] 20
PRIM_GLOW Sets WindLight prim glow intensity of a face. (To be fully functional in 1.19.2, see WindLight: Make glow scriptable. Note also that the glow is not rendered for HUDs ) integer face, float intensity
[PRIM_GLOW, ALL_SIDES, 1.0] 25
PRIM_MATERIAL Sets material of the prim PRIM_MATERIAL_xxx [PRIM_MATERIAL, PRIM_MATERIAL_RUBBER] 2
PRIM_PHANTOM Sets phantom property of an object
llSetStatus
TRUE/FALSE [PRIM_PHANTOM, TRUE] 5
PRIM_PHYSICS Sets physics property of an object
llSetStatus
TRUE/FALSE [PRIM_PHYSICS, TRUE] 3
PRIM_POINT_LIGHT Toggles light property and attributes: color, intensity, radius, and falloff. TRUE/FALSE, vector color, float intensity, float radius, float falloff [PRIM_POINT_LIGHT, TRUE, <1, 1, 1>, 1.0, 10.0, 0.75] 23
PRIM_POSITION Moves object to position.
This will silently fail for a child prim of a link set if the child prim exceeds the link distance! Also, as with llSetPos, will not move an object below ground; its center will be set at ground height.
llSetPos
vector position [PRIM_POSITION, <128, 128, 40>] 6
PRIM_ROTATION Sets the rotation of the object
llSetRot
rotation rot [PRIM_ROTATION, <0, 0, 0, 1>] 8
PRIM_SIZE Sets the scale of an object (Between <0.01,0.01,0.01> and <64,64,64>)
llSetScale
vector size [PRIM_SIZE, <4, 3, 0.1>] 7
PRIM_TEMP_ON_REZ Sets temporary on rez property of an object TRUE/FALSE [PRIM_TEMP_ON_REZ, TRUE] 4
PRIM_TYPE Sets the basic prim type; will unsit all avatars on object. See next table   9
PRIM_TEXGEN Sets the texture mapping mode, either PRIM_TEXGEN_DEFAULT or PRIM_TEXGEN_PLANAR. integer face, integer type [PRIM_TEXGEN, ALL_SIDES, PRIM_TEXGEN_DEFAULT] 22
PRIM_TEXTURE Sets the texture properties of a face
llSetTexture, llScaleTexture, llOffsetTexture, llRotateTexture
integer face, string name, vector repeats, vector offsets, float rotation
Note: name can be the name of a texture in the prim's contents or the key of a texture, but must be of type string. Seems you can use a raw key now without typecasting to string (08/08) - ED
[PRIM_TEXTURE, 0, "66864f3c-e095-d9c8-058d-d6575e6ed1b8", <1,1,1>, <0,0,0>, 0] 17
PRIM_TEXT Sets the text property of a prim
llSetText
string text, vector color, float alpha
Note: To remove text from a prim, leave text empty
[PRIM_TEXT, "Hello world", <1.0, 1.0, 1.0>, 1.0] 26
Constants for PRIM_TYPE and their parameters (these are always preceded by the prefix PRIM_TYPE ):
Constant Name Value Type Parameter(s) Example rule
PRIM_TYPE_BOX 0 Box integer holeshape, vector cut, float hollow, vector twist, vector taper_b, vector topshear [PRIM_TYPE, PRIM_TYPE_BOX, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]
PRIM_TYPE_CYLINDER 1 Cylinder integer holeshape, vector cut, float hollow, vector twist, vector taper_b, vector topshear [PRIM_TYPE, PRIM_TYPE_CYLINDER, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]
PRIM_TYPE_PRISM 2 Prism integer holeshape, vector cut, float hollow, vector twist, vector taper_b, vector topshear [PRIM_TYPE, PRIM_TYPE_PRISM, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <0.0, 0.0, 0.0>, <0.0, 0.0, 0.0>]
PRIM_TYPE_SPHERE 3 Sphere integer holeshape, vector cut, float hollow, vector twist, vector dimple [PRIM_TYPE, PRIM_TYPE_SPHERE, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>]
PRIM_TYPE_TORUS 4 Torus integer holeshape, vector cut, float hollow, vector twist, vector holesize, vector topshear, vector profilecut, vector taper_a, float revolutions, float radiusoffset, float skew [PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.25, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]
PRIM_TYPE_TUBE 5 Tube integer holeshape, vector cut, float hollow, vector twist, vector holesize, vector topshear, vector profilecut, vector taper_a, float revolutions, float radiusoffset, float skew [PRIM_TYPE, PRIM_TYPE_TUBE, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.25, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]
PRIM_TYPE_RING 6 Ring integer holeshape, vector cut, float hollow, vector twist, vector holesize, vector topshear, vector profilecut, vector taper_a, float revolutions, float radiusoffset, float skew [PRIM_TYPE, PRIM_TYPE_RING, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.25, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]
PRIM_TYPE_SCULPT 7 Sculpted string map, integer type [PRIM_TYPE, PRIM_TYPE_SCULPT, "c110440b-c276-88fb-9f3b-abf123f7ea2b", PRIM_SCULPT_TYPE_SPHERE]

For access to the old PRIM_TYPE format, use 1 instead of PRIM_TYPE - BW

Notes on the above parameters:
Parameter Note
repeats x and y range from 0.0 to 100 (z is ignored)
offsets x and y range from -1 to 1 (z is ignored)
cut/dimple/profilecut x and y range from 0.0 to 1.0, x must be at least 0.05 smaller than y (z is ignored)
hollow ranges from 0.0 (solid) to 0.95 (maximum hollowed)
twist boxes, cylinders, prisms
ranges from -0.5 (-180 degree in the edit window) to 0.5 (+180 degree in the edit window) for both x and y (z is ignored)
spheres, tubes, torii, rings
ranges from -1.0 (-360 degree in the edit window) to 1.0 (+360 degree in the edit window) for both x and y (z is ignored)
holesize


taper_b
x ranges from 0.05 to 1.0
y ranges from 0.05 (large hole) to 0.50 (no hole)
ranges from 0.0 to 2.0 for both x and y (z is ignored)
topshear ranges from -0.5 to 0.5 for both x and y (z is ignored)
taper_a ranges from -1.0 to 1.0 for both x and y (z is ignored)
revolutions ranges from 1.0 to 4.00
radiusoffset depends on holesize y and revolutions
skew
See the restrictions table on the LibraryPrimTorture page; it looks more complete.

holeshape constants (for PRIM_TYPE parameters):
Constant Value Shape
PRIM_HOLE_DEFAULT 0 default (matches the prim type: square for box, circle for cylinder, etc.)
PRIM_HOLE_SQUARE 32 square
PRIM_HOLE_CIRCLE 16 circle
PRIM_HOLE_TRIANGLE 48 triangle

type flags (for PRIM_TYPE_SCULPT parameters):
Constant Value Shape
PRIM_SCULPT_TYPE_SPHERE 1 sphere (Converge top & bottom, stitch left side to right)
PRIM_SCULPT_TYPE_TORUS 2 torus (Stitch top to bottom, stitch left side to right)
PRIM_SCULPT_TYPE_PLANE 3 plane (No stitching or converging)
PRIM_SCULPT_TYPE_CYLINDER 4 cylinder (Stitch left side to right, leave top and bottom open)

Bumpmapping constants (for PRIM_BUMP_SHINY):
Constant Value Description
PRIM_BUMP_NONE 0 none: no bump map
PRIM_BUMP_BRIGHT 1 brightness: generate bump map from highlights
PRIM_BUMP_DARK 2 darkness: generate bump map from lowlights
PRIM_BUMP_WOOD 3 woodgrain
PRIM_BUMP_BARK 4 bark
PRIM_BUMP_BRICKS 5 bricks
PRIM_BUMP_CHECKER 6 checker
PRIM_BUMP_CONCRETE 7 concrete
PRIM_BUMP_TILE 8 crustytile
PRIM_BUMP_STONE 9 cutstone: blocks
PRIM_BUMP_DISKS 10 discs: packed circles
PRIM_BUMP_GRAVEL 11 gravel
PRIM_BUMP_BLOBS 12 petridish: blobby amoebalike shapes
PRIM_BUMP_SIDING 13 siding
PRIM_BUMP_LARGETILE 14 stonetile
PRIM_BUMP_STUCCO 15 stucco
PRIM_BUMP_SUCTION 16 suction: rings
PRIM_BUMP_WEAVE 17 weave

Shininess constants (for PRIM_BUMP_SHINY):
Constant Value Description
PRIM_SHINY_NONE 0 none
PRIM_SHINY_LOW 1 low
PRIM_SHINY_MEDIUM 2 medium
PRIM_SHINY_HIGH 3 high

Material constants (for PRIM_MATERIAL):
Constant Value Description
PRIM_MATERIAL_STONE 0 stone
PRIM_MATERIAL_METAL 1 metal
PRIM_MATERIAL_GLASS 2 glass
PRIM_MATERIAL_WOOD 3 wood
PRIM_MATERIAL_FLESH 4 flesh
PRIM_MATERIAL_PLASTIC 5 plastic
PRIM_MATERIAL_RUBBER 6 rubber
PRIM_MATERIAL_LIGHT 7 light (deprecated in SL 1.9.1)

Q & A

Q: What happened to the topsize PRIM_TYPE parameter for boxes, cylinders, and prisms?
A: This was changed to taper in SL 1.10. It works exactly the same as topsize did for values from 0.0 to 1.0, but now it also accepts values from -1.0 to 0.0. Negative values shrink the bottom face instead of the top one. In this way, it is now analogous to the pre-existing taper parameter for torii, tubes, and rings.

Q: Is there any way to flip a texture within a script? You have x and y flip toggles in the edit dialog, but I can't find a way to do this from a function.
A: Yes. Use negative values in the repeats vector.

Q: With llSetPrimitiveParams, you can set almost everything about a prim that you can with llSetScale(), llSetColor(), llSetPos(), llSetRot(), etc. Will these be officially deprecated?
A: No. There are cases where the individual functions are still useful. For instance, they're significantly faster than llSetPrimitiveParams, both for scripters to write, and scripts to parse because they're simple variables and not a list, thus making them very practical for most simple manipulation of prims.

Q: Can I set a texture animation with llSetPrimitiveParams?
A: No. llSetTextureAnim remains the only way to do it.

Q: Does PRIM_POSITION use global, region, or local coordinates?
A: It works exactly like llSetPos, using region coordinates when it's the root prim and not an attachment. For child prims, or root attachments, it uses local coordinates.

Q: Is there any documentation for the old PRIM_TYPE format around anywhere?
A: Sort of, browse the revision history, anything before 8-31-2004 is before the change over; The old interface was lacking in many respects. I recommend using one of the LibraryPrimTorture encapsulation functions; they solve the problem of having to deal with the different number of paramaters required for each prim type.

Q: What is up with taper_a & taper_b?
A: Before SL 1.11 boxs, cylinders & prisms had an attribute called top_size, ranging from 0.0 (no top) to 1.0 (full top). In 1.11 they retrofitted the attribute so that it could adjust the size of the bottom of the prim aswell. For lack of a better name, they renamed the attribute to taper (taper_b). What they did not do was adjust the range to be the same as in the client, as that would break existing content (I suggested they create a new PRIM_TYPE flag like they had in the past; they did not). In the client they made the range -1.0 -> 1.0, while in scripting the range was to be 0.0 -> 2.0 (to convert do: 1.0 - value). To confuse things the old top_size attribute occupies the same address in the object description structure as hole_size. Since taper_a, taper_b have different ranges, occupy different address and co-exist, for sake of sanity and readabilty I have renamed them for this piece of documentation. I meant to fix the documentation earlier it just slipped my mind. -- BW

Q: Help! This function doesn't typecast the parameters, and I'm getting non-integer rule errors and stuff!
A: Try this magical function that figures out what datatypes the list elements appear to be and casts them to the right thing...
///////////////////////////////////////////////////////////////////////////////
//
// ccFixListDatatypes
//      Walks a list and casts the data to the appropriate type, then returns
//  the cast list.  Useful for things like llSetPrimitiveParams when data is
//  parsed from strings.
//
//  v3 - Initial public release
//  v4 - Fixes parsing of negative elements in vectors and rotations.
//
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2008, Ceawlin Creations
// All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// 
//     * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//     * Neither the name of Ceawlin Creations, Liandra Ceawlin, or A. J.
// Taylor, nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written
// permission.
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////

// This code is far from optimal, lol.
list    ccFixListDatatypes( list l )
{
    //Liandra Ceawlin 2008-09-20
    integer i;
    for( i=0; i<llGetListLength(l); i++ )
    {
        integer is_integer = TRUE;
        integer is_float = TRUE;
        integer is_vector = TRUE;
        integer is_rot = TRUE;
        integer j;
        string s = llStringTrim(llList2String(l,i),STRING_TRIM);
        if( s == "" )
            jump cont1;
        for( j=0; j<llStringLength(s); j++ )
        {
            string c = llGetSubString(s,j,j);
            if( (integer)c==0 && c!="0" )
            {
                is_integer = FALSE;
                if( c != "." )
                    is_float = FALSE;
            }
        }
        if( llGetSubString(s,0,0)=="<" && llGetSubString(s,llStringLength(s)-1,llStringLength(s)-1)==">" )
        {
            string tmp = llDeleteSubString(s,0,0);
            tmp = llDeleteSubString(tmp,llStringLength(tmp)-1,llStringLength(tmp)-1);
            list tl = llParseString2List(tmp,[","],[]);
            if( llGetListLength(tl) == 3 )
                is_rot = FALSE;
            else if( llGetListLength(tl) == 4 )
                is_vector = FALSE;
            else
            {
                is_rot = FALSE;
                is_vector = FALSE;
                jump cont2;
            }
            for( j=0; j<llGetListLength(tl); j++ )
            {
                integer k;
                string ts = llStringTrim(llList2String(tl,j),STRING_TRIM);
                for( k=0; k<llStringLength(ts); k++ )
                {
                    string tc = llGetSubString(ts,k,k);
                    if( (integer)tc==0 && tc!="0" && tc!="." && tc!="-" )
                    {
                        is_rot=FALSE;
                        is_vector = FALSE;
                        jump cont3;
                    }
                }
            }
        }
        else
        {
            is_vector = FALSE;
            is_rot = FALSE;
        }
        list n;
        if( is_integer )
            n += (integer)s;
        else if( is_float )
            n += (float)s;
        else if( is_vector )
            n += (vector)s;
        else if( is_rot )
            n += (rotation)s;
        else
            jump cont4;
        l = llListReplaceList(l,n,i,i);
        @cont1;
        @cont2;
        @cont3;
        @cont4;
    }
    return l;
}

default
{
    on_rez( integer param )
    {
        llSay( 0, "Open your script error/warning window and touch me to run the test." );
    }
    
    touch_start(integer det)
    {
        llSay( DEBUG_CHANNEL, "Testing..." );
        list shape= llGetPrimitiveParams([PRIM_TYPE]);
        
        // cast shape to all strings, like we just parsed it out of some chat or something....
        integer i;
        for( i=0; i<llGetListLength(shape); i++ )
            shape = llListReplaceList( shape, [llList2String(shape,i)], i, i );
            
        llSay( DEBUG_CHANNEL, "This will cause an error." );
        llSetPrimitiveParams( shape );
        
        // Cast the string list into the proper datatypes.
        list new = ccFixListDatatypes( shape );
        llSay( DEBUG_CHANNEL, "But this shouldn't..." );
        llSetPrimitiveParams( [PRIM_TYPE]+new );
        
        llSay( DEBUG_CHANNEL, "Done." );
    }        
}
-- LiandraCeawlin


See also llGetPrimitiveParams, llSetLinkPrimitiveParams.


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Prim
There are 25 comments on this page. [Display comments/form]