LlGetLinkPrimitiveParams
Looking for the current API? Open the llGetLinkPrimitiveParams reference →
Shared wiki article
This page transcludes LlGetPrimitiveParams. The following text is from that archived revision.
Overview
link parameter, and does not cause the script to sleep.- Supplying a prim or object flag will return that flag's attributes.
- Face flags require the user to also supply a side parameter.
Function variants
llGetPrimitiveParams
Function notes
llGetLinkPrimitiveParams
Wiki description
link number given.Specification
Archived get parameter table from Template:LSL Constants/PrimitiveParams. Variable-based or conditional cells retain their original syntax.
Caveats
- PRIM_LINK_TARGET is a special parameter which can be inserted to perform actions on multiple prims on the linkset with one call.
- Passing 0 (zero) as the link number in the formal link parameter on a linked object will return an empty list.
- The legacy value of PRIM_TYPE, 1 (which is often referred to as PRIM_TYPE_LEGACY), is not supported by this function as a flagllGetPrimitiveParams came after PRIM_TYPE_LEGACY was deprecated..
Examples
default
{
state_entry()
{
list params = llGetPrimitiveParams([PRIM_POINT_LIGHT]);
integer isLight = llList2Integer(params, 0);
string msg = "Object is ";
if (!isLight) // read as "not isLight"
msg += "not a light source.";
else
{
msg += "a point light source.";
// llList2String will automatically typecast
msg += "\n\tColour = " + llList2String(params, 1);
msg += "\n\tIntensity = " + llList2String(params, 2);
msg += "\n\tRadius = " + llList2String(params, 3);
msg += "\n\tFalloff = " + llList2String(params, 4);
}
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.");
}
}Helper functions
list GetPrimitiveParams(list input)
{//Returns a list that can be fed to llSetPrimitiveParams
integer link = LINK_THIS;
list output;
integer c = ~llGetListLength(input);
while(0x80000000 & (c = - ~c))
{
integer f = llList2Integer(input, c);
list flag = (list)f;
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 if(PRIM_LINK_TARGET ^ f)
output += flag + (link = llList2Integer(input, (c = - ~c)));
else
output += flag + llGetLinkPrimitiveParams(link, flag );
}
return output;
}
//Contributed by Strife Onizukalist GetLinkPrimitiveParams(integer link, list input)
{//Returns a list that can be fed to llSetPrimitiveParams
list output;
integer c = ~llGetListLength(input);
while(0x80000000 & (c = - ~c))
{
integer f = llList2Integer(input, c);
list flag = (list)f;
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 if(PRIM_LINK_TARGET ^ f)
output += flag + (link = llList2Integer(input, (c = - ~c)));
else
output += flag + llGetLinkPrimitiveParams(link, flag );
}
return output;
}
//Contributed by Strife OnizukaSee also: functions
History
- Date of release llGetLinkPrimitiveParams 29-03-2010
Shared wiki helpers
The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.
Template:LSL Function/link-face
Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}{{#if:{{{1|}}}|{{LSL Function/link|{{{1}}}|nogroup={{{nogroup|}}}}}}}{{#if:{{{2|}}}|{{LSL_Function/face|{{{2}}}}}}}{{#if:
{{#vardefine:also_functions|{{#var:also_functions}}
{{LSL DefineRow||[[llGetLinkNumberOfSides]]|Returns the number of faces of the linked prim.}}}}
}}Template:LSL PrimitiveParam Categorize
Original shared helper source (conditional wiki logic is not evaluated)
{{#if:{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||{{#vardefine:hidden-text|{{#var:hidden-text}}
{{#ifexist:Template:LSLC{{#var:lang}}|
{{LSLC{{#var:lang}}|PrimitiveParams}}
{{LSLC{{#var:lang}}|PrimitiveParams/{{{1}}}}}
{{LSLC{{#var:lang}}|{{{1}}}}}
|
{{LSLC|PrimitiveParams{{#var:lang}}}}
{{LSLC|PrimitiveParams/{{{1}}}{{#var:lang}}}}
{{LSLC|{{{1}}}{{#var:lang}}}}
}}
}}}}Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.