LlGetLinkPrimitiveParams - Second Life Wiki

LlGetLinkPrimitiveParams

From Second Life Wiki

Second Life Wiki > LSL Portal > Built-in Functions > LlGetLinkPrimitiveParams
Jump to: navigation, search

Summary

Function: list llGetLinkPrimitiveParams( integer link, list params );

Identical to llGetPrimitiveParams except that it acts on the prim specified by the link number given.
Returns the list of primitive attributes requested in the params list for link

• integer link Link number (0: unlinked, 1: root prim, >1: child prims) or a LINK_* flag to get the parameters of
• list params PRIM_* flags

PRIM_* flags can be broken into three categories, face flags, prim flags, and object flags.

  • Supplying a prim or object flag will return that flags attributes.
  • Face flags require the user to also supply a side parameter.
Flag Description
LINK_ROOT 1 sends to the root prim in a multi-prim linked set[1]
Flag Description
LINK_THIS -4 sends to the prim the script is in
Parameter Return Values Description
PRIM_NAME ] 27 [ string name ] Name: llGetObjectName
PRIM_DESC ] 28 [ string description ] Description: llGetObjectDesc
PRIM_TYPE ] 9 [ integer flag ] Gets the prim shape.
flag Constants Additional Return Values
PRIM_TYPE_BOX 0 [ integer hole_shape, vector cut, float hollow, vector twist, vector top_size, vector top_shear ]
PRIM_TYPE_CYLINDER 1 [ integer hole_shape, vector cut, float hollow, vector twist, vector top_size, vector top_shear ]
PRIM_TYPE_PRISM 2 [ integer hole_shape, vector cut, float hollow, vector twist, vector top_size, vector top_shear ]
PRIM_TYPE_SPHERE 3 [ integer hole_shape, vector cut, float hollow, vector twist, vector dimple]
PRIM_TYPE_TORUS 4 [ integer hole_shape, vector cut, float hollow, vector twist, vector hole_size, vector top_shear, vector advanced_cut, vector taper, float revolutions, float radius_offset, float skew ]
PRIM_TYPE_TUBE 5 [ integer hole_shape, vector cut, float hollow, vector twist, vector hole_size, vector top_shear, vector advanced_cut, vector taper, float revolutions, float radius_offset, float skew ]
PRIM_TYPE_RING 6 [ integer hole_shape, vector cut, float hollow, vector twist, vector hole_size, vector top_shear, vector advanced_cut, vector taper, float revolutions, float radius_offset, float skew ]
PRIM_TYPE_SCULPT 7 [ string mapinteger type ] Sculpted_Prims:_FAQ
  hole_shape Flags Shape hole_shape Flags Shape
PRIM_HOLE_DEFAULT 0x00 Default PRIM_HOLE_SQUARE 0x20 Square
PRIM_HOLE_CIRCLE 0x10 Circle PRIM_HOLE_TRIANGLE 0x30 Triangle
type Flags Style Description
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.
PRIM_SCULPT_TYPE_A 5 Mesh model With this subtype, PRIM_TYPE_SCULPT's map parameter is read-only, when read NULL_KEY is returned.In other words this can only be used to determine that a prim is of the mesh subtype.
PRIM_SCULPT_FLAG_ZZZZZZZZ 63
PRIM_SCULPT_FLAG_INVERT 64 Invert Render inside out (inverts the normals).
PRIM_SCULPT_FLAG_MIRROR 128 Mirror Render an X axis mirror of the sculpty.
PRIM_SLICE ] 35 [ vector slice ] Gets the prim's slice (a shape attribute).
PRIM_PHYSICS_SHAPE_TYPE ] 30 [ integer type ] Gets the prim's physics shape type.
type Flags V Description Notes
PRIM_PHYSICS_SHAPE_PRIM 0 Use the normal prim shape for physics default for all non-mesh objects
PRIM_PHYSICS_SHAPE_CONVEX 2 Use the convex hull of the prim shape for physics default for all mesh objects
PRIM_PHYSICS_SHAPE_NONE 1 Ignore this prim in the physics shape. This cannot be applied to the root prim or avatars.
PRIM_MATERIAL ] 2 [ integer material ] Gets the prim's material. The material determines the default collision sound, sprite, friction coefficient and restitution coefficient.
material Flags Description Friction Restitution
PRIM_MATERIAL_STONE 0 stone 0.8 0.4
PRIM_MATERIAL_METAL 1 metal 0.3 0.4
PRIM_MATERIAL_GLASS 2 glass 0.2 0.7
PRIM_MATERIAL_WOOD 3 wood 0.6 0.5
PRIM_MATERIAL_FLESH 4 flesh 0.9 0.3
PRIM_MATERIAL_PLASTIC 5 plastic 0.4 0.7
PRIM_MATERIAL_RUBBER 6 rubber 0.9 0.9
PRIM_MATERIAL_LIGHT 7 light, DEPRECATED: Looks the same as [ PRIM_FULLBRIGHT, ALL_SIDES, TRUE ] 0.6 0.5
PRIM_PHYSICS ] 3 [ integer boolean ] Physics status llGetStatus
PRIM_TEMP_ON_REZ ] 4 [ integer boolean ] Temporary attribute
PRIM_PHANTOM ] 5 [ integer boolean ] Phantom status llGetStatus
PRIM_POSITION ] 6 [ vector position ] Position, llGetPos
PRIM_POS_LOCAL ] 33 [ vector position ] Local position, llGetLocalPos
PRIM_ROTATION ] 8 [ rotation rot ] Global rotation, llGetRot
PRIM_ROT_LOCAL ] 29 [ rotation rot ] Local rotation, llGetLocalRot
PRIM_SIZE ] 7 [ vector size ] Size, llGetScale
PRIM_TEXTURE, integer face ] 17 [ string texture, vector repeats, vector offsets, float rotation_in_radians ]
Texture: llGetTexture
Repeats: llGetTextureScale
Offset: llGetTextureOffset
Rotation: llGetTextureRot
PRIM_TEXT ] 26 [ string text, vector color, float alpha ] Floating Text: NA
PRIM_COLOR, integer face ] 18 [ vector color, float alpha ]
Alpha: llGetAlpha
Color: llGetColor
PRIM_BUMP_SHINY, integer face ] 19 integer shiny, integer bump ]
shiny & bump Flags Description
PRIM_SHINY_NONE 0 none
PRIM_SHINY_LOW 1 low
PRIM_SHINY_MEDIUM 2 medium
PRIM_SHINY_HIGH 3 high
PRIM_BUMP_NONE 0 none: no bump map
PRIM_BUMP_BRIGHT 1 brightness: generate from highlights
PRIM_BUMP_DARK 2 darkness: generate 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 amoeba like 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
PRIM_FULLBRIGHT, integer face ] 20 [ integer boolean ]
PRIM_FLEXIBLE ] 21 [ integer boolean, integer softness, float gravity, float friction, float wind, float tension, vector force ]
PRIM_TEXGEN, integer face ] 22 [ integer mode ]
mode Constants Description
PRIM_TEXGEN_DEFAULT 0 The texture repeats units are in texture repeats per face.
PRIM_TEXGEN_PLANAR 1 The texture repeats units are in texture repeats per half meter. This is in contrast to the in-world editing tool, in which the planar texture scaling units are repeats per meter.
PRIM_POINT_LIGHT ] 23 [ integer boolean, vector color, float intensity, float radius, float falloff ]
PRIM_GLOW, integer face ] 25 [ float intensity ]
PRIM_OMEGA ] 32 vector axis, float spinrate, float gain ] llTargetOmega
34 integer link_target ] Multiple llGetLinkPrimitiveParams calls.
PRIM_CAST_SHADOWS ] 24 [ integer boolean ] DEPRECATED: Shadow casting for the primitive

Caveats

  • link needs to be either an actual link number or a link constants that equate to a single prim, such as LINK_ROOT and LINK_THIS.
  • The prim description is limited to 127 bytes, any string longer then that will be truncated. This truncation does not always happen when the attribute is set or read.
  • The pipe character '|' and the newline character '\n' are not legal in a prim's description, they will be replaced by with '?'[2].
  • Note that when people have "Hover Tips on All Objects" selected in the viewer's "View" menu, they'll see the object description pop-up for any object under their mouse pointer. For that reason, it is good practice to only set human-friendly information in the description (e.g. keys and such).
  • When an attached object is detached, changes made by script to the name and description (of the root prim) of the attachment will be lost. While the object is attached the name and description can be changed but it will not be reflected in inventory. This caveat does not apply to child prims.
  • repeats is not only used to get the number of repeats but the sign of the individual components indicate if "Flip" is set.
  • In the default texture mapping mode the texture repeats units are in texture repeats per face. In the planar texture mapping mode the texture repeats units are in texture repeats per half meter. This is in contrast to the in-world editing tool, in which the planar texture scaling units are repeats per meter.
  • Do not rely on Floating Text as a storage medium; it is neither secure nor finalized.
    • Floating text has been altered in past server updates, breaking existing content; future changes may occur.
    • Even "invisible"[3] floating text is transmitted to the client.
      • It can be viewed by anyone with a client that is capable of rendering text that is supposed to be invisible.
      • The network packets that contain the text can be sniffed and the text read.
  • top_size and client values are different, the ranges do not line up, conversion is required. This simple equation can be used: answer = 1.0 - value. See top_size Explained for more information.
  • The value of map is NULL_KEY when the owner does not have full permissions to the object and the map asset is not in the prim's inventory.
  • If map is missing from the prim's inventory and it is not a UUID or it is not a texture then an error is shouted on DEBUG_CHANNEL.
  • If map is a UUID then there are no new asset permissions consequences for the object.
    • The resulting object develops no new usage restrictions that might have occurred if the asset had been placed in the prims inventory.
  • position is always in region coordinates, even if the prim is a child or the root prim of an attachment.
  • rot is always the global rotation, even if the prim is a child or the root prim of an attachment.
  • PRIM_ROTATION incorrectly reports the avatars rotation when called on the root of an attached object. Use PRIM_ROT_LOCAL for the root prim instead.
  • PRIM_OMEGA on nonphysical objects, and child prims of physical objects, is only a client side effect; the object or prim will collide as non-moving geometry.
  • PRIM_OMEGA cannot be used on avatars sitting on the object. It will emit the error message "PRIM_OMEGA disallowed on agent".
  • If PRIM_OMEGA does not appear to be working, make sure that that Develop > Network > Velocity Interpolate Objects is enabled on the viewer.
  • If link (or PRIM_LINK_TARGET's link_target) describes a seated avatar...
flag Flag return for a single face.
[ PRIM_COLOR ] ZERO_VECTOR, 0.0 ]
[ PRIM_GLOW ] 0.0 ]
[ PRIM_TEXGEN ] PRIM_TEXGEN_DEFAULT ]
[ PRIM_TEXTURE ] "", ZERO_VECTOR, ZERO_VECTOR, 0.0 ]
[ PRIM_FULLBRIGHT ] FALSE ]
PRIM_BUMP_SHINY ] PRIM_SHINY_NONE, PRIM_BUMP_NONE ]
  • If face is ALL_SIDES then the flag works on all sides.
  • If face indicates a face that does not exist the flag returns nothing.
  • The legacy value of PRIM_TYPE, 1, is not supported by this function as a flag[6].
All Issues ~ Search JIRA for related Bugs

Examples

To test whether an object is a point light source, and if so get its parameters:

string msg = "Object is ";
integer isLight;
vector colour;
float intensity;
float radius;
float falloff;
list params = llGetLinkPrimitiveParams(LINK_THIS, [PRIM_POINT_LIGHT]);
isLight = llList2Integer(params, 0);
if (isLight == FALSE)
    msg += "not a light source.";
else
{
    colour = llList2Vector(params, 1);
    intensity = llList2Float(params, 2);
    radius = llList2Float(params, 3);
    falloff = llList2Float(params, 4);
    msg += "a point light source.\nColour = "+(string)colour;
    msg += "\nIntensity = "+(string)intensity;
    msg += "\nRadius = "+(string)radius;
    msg += "\nFalloff = "+(string)falloff;
}
llSay(0, msg);
//code snippets by Strife Onizuka, Xen Lisle and Kireji Haiku
integer AreAllPrimsAreGlowing()
{
	//The root prim is either link number is 0 or 1
	//It is only zero if it is a single prim object with no avatars sitting on it.
	//llGetNumberOfPrims() returns the number of prims and seated avatars.
	integer link = llGetNumberOfPrims() > 1;
 
	//We want to loop over all prims but not avatars, so we need to know how many prims there are.
	//Fortunately the avatars are added to the end of the link set, their link numbers always come after the last prim.
	//llGetObjectPrimCount(llGetKey()) only returns only the number of prims, it doesn't count avatars.
	//To determine the upper bound, we need to take into consideration the link number of the root prim.
	integer end = link + llGetObjectPrimCount(llGetKey());
 
	for(;link < end; ++link)//loop through all prims
	{
		if( llListStatistics(LIST_STAT_MAX, llGetLinkPrimitiveParams(link, [PRIM_GLOW, ALL_SIDES])) <= 0.0)
		{//we can exit early because we know that if this value is less than or equal to zero, so will the minimum
			return FALSE;
		}
	}
	//we didn't find a single value that was less than or equal to zero, QED, they are all greater than zero.
	return TRUE;
}
 
default
{
	touch_start(integer num_detected)
	{
		if(AreAllPrimsAreGlowing())
			llSay(0, "All prims glowing.");
		else
			llSay(0, "Not all prims glowing.");
	}
}

Useful Snippets

list GetLinkPrimitiveParams(integer link, list input)
{//Returns a list that can be fed to llSetPrimitiveParams
    list output;
    integer c = ~llGetListLength(input);
    while(0x80000000 & (c = - ~c))
    {
        list flag = (list)llList2Integer(input, c);
        if(~llListFindList([PRIM_BUMP_SHINY, PRIM_COLOR, PRIM_TEXTURE, 
                            PRIM_FULLBRIGHT, PRIM_TEXGEN, PRIM_GLOW], flag ))
        {
            integer side = llList2Integer(input, (c = - ~c));
            if(~side)//pop the stack
                output += flag + side + llGetLinkPrimitiveParams(link, flag + side );
            else
                for(side = llGetLinkNumberOfSides(link); side; ) //we return the sides in reverse order, easier to code; runs faster.
                    output += flag + side + llGetLinkPrimitiveParams(link, flag + (side = ~ -side) );
        }
        else
            output += flag + llGetLinkPrimitiveParams(link, flag );
    }
    return output;
}
//Contributed by Strife Onizuka

SetPrimitiveParams-Example by Anylyn Hax makes reading primitive parameters easy.

Notes

Link Numbers

Each prim that makes up an object has an address, a link number. To access a specific prim in the object, the prim's link number must be known. In addition to prims having link numbers, avatars seated upon the object do as well.

  • If an object consists of only one prim, and there are no avatars seated upon it, the (root) prim's link number is zero.
  • However, if the object is made up of multiple prims or there is an avatar seated upon the object, the root prim's link number is one.

When an avatar sits on an object, it is added to the end of the link set and will have the largest link number. In addition to this, while an avatar is seated upon an object, the object is unable to link or unlink prims without unseating the avatars first.

Counting Prims & Avatars

There are two functions of interest when trying to find the number of prims and avatars on an object.

integer GetPrimCount() { //always returns only the number of prims
    if(llGetAttached())//Is it attached?
        return llGetNumberOfPrims();//returns avatars and prims but attachments can't be sat on.
    return llGetObjectPrimCount(llGetKey());//returns only prims but won't work on attachments.
}
See llGetNumberOfPrims for more about counting prims and avatars.

Link Numbers

Each prim that makes up an object has an address, a link number. To access a specific prim in the object, the prim's link number must be known. In addition to prims having link numbers, avatars seated upon the object do as well.

  • If an object consists of only one prim, and there are no avatars seated upon it, the (root) prim's link number is zero.
  • However, if the object is made up of multiple prims or there is an avatar seated upon the object, the root prim's link number is one.

When an avatar sits on an object, it is added to the end of the link set and will have the largest link number. In addition to this, while an avatar is seated upon an object, the object is unable to link or unlink prims without unseating the avatars first.

Counting Prims & Avatars

There are two functions of interest when trying to find the number of prims and avatars on an object.

integer GetPrimCount() { //always returns only the number of prims
    if(llGetAttached())//Is it attached?
        return llGetNumberOfPrims();//returns avatars and prims but attachments can't be sat on.
    return llGetObjectPrimCount(llGetKey());//returns only prims but won't work on attachments.
}
See llGetNumberOfPrims for more about counting prims and avatars.

See Also

Functions

•  llGetLinkNumber Returns the link number of the prim the script is in.
•  llGetLinkNumber Returns the link number of the prim the script is in.
•  llSetLinkPrimitiveParamsFast Set many primitive parameters without delay
•  llSetLinkPrimitiveParams Set many primitive parameters
•  llSetPrimitiveParams Set many primitive parameters
•  llGetPrimitiveParams Get many primitive parameters
•  llGetObjectDetails

Articles

•  Limits SL limits and constrictions
•  Color in LSL
•  Translucent Color
•  Color in LSL
•  Translucent Color

Deep Notes

PRIM_TYPE top_size and client taper conversion
Range[4] Top
Tapered
No
Tapering
Bottom
Tapered
Client [-1, 1] 1.0 0.0 -1.0
PRIM_TYPE [0, 2] 0.0 1.0 2.0
LEGACY [0, 1] 0.0 1.0 NA
Client < 1.11 [0, 1] 0.0 1.0 NA

top_size Explained

When the original PRIM_TYPE interface was retired (PRIM_TYPE_LEGACY, SL 1.5), the new PRIM_TYPE interface did not yet support tapering of the bottom of the prim, this feature wasn't added until SL 1.11 (two years later). Instead of retiring the new PRIM_TYPE when it was added, the range of top_size was enlarged; meanwhile in the client they redefined the parameter and it's values. This redefinition and range enlargement resulted in two interfaces that did the same thing but achieved it through different values. Meanwhile PRIM_TYPE_LEGACY's interface was not updated to support tapering of the bottom of the prim. Consequently all three interfaces have different ranges, making for a rather nasty caveat.

Search JIRA for related Issues

Footnotes

  1. ^ LINK_ROOT does not work on single prim objects!
  2. ^ The pipe character historically has been used to separate fields in the serialized version of inventory. The field is not multi-line so the newline character holds no meaning in this context.
  3. ^ Floating text with an alpha set to 0.0 is rendered "invisible"
  4. ^ The ranges in this article are written in Interval Notation.
  5. ^ Avatars really have 29 textures, llGetLinkNumberOfSides however returns 0 - SVC-6646[c].
  6. ^ llGetPrimitiveParams came after PRIM_TYPE_LEGACY was deprecated.
This article wasn't helpful for you? Maybe the related article at the LSL Wiki is able to bring enlightenment.