Difference between revisions of "LlSetLinkPrimitiveParams"

From Second Life Wiki
Redirect page
Jump to: navigation, search
m (moved example script showing use of llSetLinkPrimitiveParams in combination with PRIM_LINK_TARGET into side-by-side comparison table)
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{LSL Function
+
#redirect[[llSetPrimitiveParams#llSetLinkPrimitiveParams]]
|inject-2={{Issues/SVC-2105}}{{LSL Function/link-face|link}}{{LSL PrimitiveParam Categorize|Link}}
+
{{:llSetPrimitiveParams|default=llSetLinkPrimitiveParams}}
|func_id=328|func_sleep=0.2|func_energy=10.0
+
|func=llSetLinkPrimitiveParams|sort=SetLinkPrimitiveParams
+
|p1_type=integer|p1_name=link
+
|p2_type=list|p2_name=rules
+
|func_desc=Set primitive parameters for {{LSLP|link}} based on {{LSLP|rules}}. You may prefer to use [[llSetLinkPrimitiveParamsFast]] which behaves identically except does not sleep the script.
+
|spec
+
|caveats=*Applying an operation to [[LINK_SET]] is applied first to the root prim, then to each child prim.
+
*[[llGetLinkPrimitiveParams]] can be used to get corresponding parameters from linked prims.
+
* [[PRIM_LINK_TARGET]] is a special paramter which can be inserted to perfom actions on multiple prims on the linkset with one call.
+
* [[PRIM_ROTATION]] is bugged in child prims, use [[PRIM_ROT_LOCAL]] instead or see [[llSetLinkPrimitiveParams#Useful_Snippets|Useful Snippets]] for a workaround, or the linked SVC-93 issue below.
+
* '''Some prim properties are reset''' by this function
+
** A flexible prim will become not flexible
+
** A sliced prim will become unsliced
+
: In order to preserve properties they must be saved and explicitly set in the function call
+
{{LSL Tip|This function has a delay of 0.2 seconds per call. Please consider using [[llSetLinkPrimitiveParamsFast]] instead. You can do exactly the same that way, just without the delay.}}
+
{{LSL Tip|When wanting to change the alpha value of a face, please consider using [[llSetLinkAlpha]](integer link, float alpha, integer face); instead of [[llSetLinkPrimitiveParams]](integer link, [ [[PRIM_COLOR]], integer face, vector color, float alpha ]);, that way you don't have to mess with the color settings and don't get a 0.2 seconds delay per call.}}
+
|constants={{LSL Constants/PrimitiveParams|set|remote=true}}
+
|examples =
+
A simple script to light up a prim in a [[linkset]] when touched, and unlight the others using llSetLinkPrimitiveParams, when script is installed in the root prim of the linkset.
+
<lsl>
+
default
+
{
+
    touch_start(integer total_number)
+
    {
+
        // Turn off all prims
+
        llSetLinkPrimitiveParams(LINK_SET,[PRIM_FULLBRIGHT,ALL_SIDES,FALSE]);
+
        // Turn on the one that was touched
+
        llSetLinkPrimitiveParams(llDetectedLinkNumber(0),[PRIM_FULLBRIGHT,ALL_SIDES,TRUE]);       
+
    }
+
}
+
</lsl>
+
{{LSL Tip|You can use one function call instead of two when making use of [[PRIM_LINK_TARGET]]. Do pay attention though that [[llSetLinkPrimitiveParams]] still does have a 0.2 seconds delay per function call, while [[llSetLinkPrimitiveParamsFast]] does not.}}
+
{{{!}} class="sortable" width="100%" {{Prettytable}}
+
{{!}}- {{Hl2}}
+
! '''Preferred method using [[PRIM_LINK_TARGET]]'''
+
! '''Second method does the same effect-wise.'''
+
{{!}}-
+
{{!!}}<lsl>
+
default
+
{
+
    touch_start(integer num_detected)
+
    {
+
    //  color the root prim red and the first linked-prim green
+
 
+
        llSetLinkPrimitiveParams(LINK_ROOT,
+
                [PRIM_COLOR, ALL_SIDES, <1.0, 0.0, 0.0>, 1.0,
+
            PRIM_LINK_TARGET, 2,
+
                PRIM_COLOR, ALL_SIDES, <0.0, 1.0, 0.0>, 1.0]);
+
    }
+
}
+
</lsl>
+
{{!!}}
+
<lsl>
+
default
+
{
+
    touch_start(integer num_detected)
+
    {
+
    //  color the root prim red and the first linked-prim green
+
 
+
        llSetLinkPrimitiveParams(LINK_ROOT,
+
                [PRIM_COLOR, ALL_SIDES, <1.0, 0.0, 0.0>, 1.0]);
+
        llSetLinkPrimitiveParams(2,
+
                [PRIM_COLOR, ALL_SIDES, <0.0, 1.0, 0.0>, 1.0]);
+
    }
+
}
+
</lsl>
+
{{!}}}
+
|helpers=
+
<lsl> //-- PRIM_ROTATION workaround for child prims (works in unattached objects only)
+
llSetLinkPrimitiveParams( linknumber, [PRIM_ROT_LOCAL, rot * llGetRootRotation()] )
+
 
+
//-- PRIM_ROTATION workaround for child prims (works in linked objects only)
+
llSetLinkPrimitiveParams( linknumber, [PRIM_ROT_LOCAL, rot * llList2Rot( llGetLinkPrimitiveParams( LINK_ROOT, [PRIM_ROT_LOCAL] ), 0 )] )
+
+
//-- PRIM_ROTATION workaround for child prims (works in all scenarios)
+
llSetLinkPrimitiveParams( linknumber, [PRIM_ROT_LOCAL, rot * llList2Rot( llGetLinkPrimitiveParams( !!llGetLinkNumber(), [PRIM_ROT_LOCAL] ), 0 )] )</lsl>
+
|also_functions=
+
{{LSL DefineRow||[[llSetPrimitiveParams]]|Set many primitive parameters}}
+
{{LSL DefineRow||[[llSetLinkPrimitiveParamsFast]]|Set many primitive parameters without sleep on link objects}}
+
{{LSL DefineRow||[[llGetPrimitiveParams]]|Get many primitive parameters}}
+
{{LSL DefineRow||[[llGetLinkPrimitiveParams]]|Get many primitive parameters of link objects}}
+
{{LSL DefineRow||[[llSetLinkAlpha]]|}}
+
{{LSL DefineRow||[[llSetLinkColor]]|}}
+
{{LSL DefineRow||[[llSetLinkTexture]]|}}
+
|also_tests
+
|also_events
+
|also_articles
+
|notes=
+
===[[PRIM_POSITION]]===
+
{{#var:PRIM_POSITION/SLPP&A}}
+
|cat1=Prim
+
|cat2=Movement
+
|cat3=Status
+
|cat4=Texture
+
|cat5=Object
+
|cat6=Sit/Teleport
+
|cat7=Link/Set
+
|cat8
+
}}
+

Latest revision as of 16:37, 12 September 2013