Difference between revisions of "User:Strife Onizuka/PrimitiveParams"

From Second Life Wiki
Jump to navigation Jump to search
(Minor copyediting)
m (Blanked the page)
 
Line 1: Line 1:
{{LSL Function/Headless|self=*
|inject-2={{Issues/SVC-2105}}{{LSL Function/link-face|link}}{{LSL PrimitiveParam Categorize|Link}}
|summary=These functions are almost entirely identical. For almost all situations we recommend you use [[#llSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]].


They are very powerful & sharp functions. Each PRIM_* rule takes at least one parameter and has its own quirks and its own dedicated article with specific information.
There are two differences:
* How long does it force the script to sleep?
*: '''Zero''': [[#llSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]]
*: '''200 milliseconds''': [[#llSetPrimitiveParams|llSetPrimitiveParams]] [[#llSetLinkPrimitiveParams|llSetLinkPrimitiveParams]]
* Does it have a {{LSLP|link}} parameter?
*: '''No''': [[#llSetPrimitiveParams|llSetPrimitiveParams]]
*: '''Yes''': [[#llSetLinkPrimitiveParams|llSetLinkPrimitiveParams]] [[#llSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]]
|func=llSetPrimitiveParams|sort=SetPrimitiveParams
|head={{LSL Function/Head
|func_id=259|func_sleep=0.2|func_energy=10.0
|func=llSetPrimitiveParams
|p1_type=list|p1_name=rules
|func_desc=Sets the prim's parameters according to {{LSLP|rules}}.
|func_footer=Please consider using [[#llSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]] in combination with [[LINK_THIS]] instead. You avoid the 0.2 second delay.
|caveats
}}{{LSL Function/Head
|func_id=328|func_sleep=0.2|func_energy=10.0
|func=llSetLinkPrimitiveParams
|p1_type=list|p1_name=link
|p2_type=list|p2_name=rules
|func_desc=Sets the prims parameters according to {{LSLP|rules}}.
|func_footer=Please consider using [[#llSetLinkPrimitiveParamsFast|llSetLinkPrimitiveParamsFast]] instead. You avoid the 0.2 second delay.
|caveats
}}{{LSL Function/Head
|func_id=353|func_sleep=0.0|func_energy=10.0
|func=llSetLinkPrimitiveParamsFast
|p1_type=list|p1_name=link
|p2_type=list|p2_name=rules
|func_desc=Sets the prims parameters according to {{LSLP|rules}}.
|func_footer
|caveats
}}
|caveats=
* [[PRIM_LINK_TARGET]] is a special parameter which can be inserted to perform actions on multiple prims on the linkset with one call.
*Scripts written before September 2004 that use [[PRIM_TYPE]] depend on PRIM_TYPE to have the value 1; if these scripts are recompiled, the new value of {{HoverText|PRIM_TYPE|Value: 9}} will be used, causing errors at runtime.
**To fix this, replace the PRIM_TYPE flag with the value 1 or update to the newer PRIM_TYPE syntax.
* [[PRIM_ROTATION]] is bugged in child prims. See [[llSetPrimitiveParams#Useful_Snippets|Useful Snippets]] for a workaround, or the linked SVC-93 issue below.
* This function will return an error if fed data of the wrong type. This is problematic when feeding data into it from user input or notecard. To remedy this, see this List Cast function: [[list_cast]]
* '''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|When wanting to change the alpha value of a face, please consider using [[llSetAlpha]](float alpha, integer face); instead of [[llSetPrimitiveParams]]([ [[PRIM_COLOR]], integer face, vector color, float alpha ]);, that way, you don't have to mess with the color settings. (And there is no 0.2 second delay.)}}
|constants={{LSL Constants/PrimitiveParams|set}}
|examples=<lsl>
// To color all sides of a prim black, except side 3 white
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <0.0,0.0,0.0>, 1.0]);
llSetPrimitiveParams([PRIM_COLOR, 3, <1.0,1.0,1.0>, 1.0]);
// To render on side 3
// the picture with the UUID...
// and the repeats per face as vector,
// the texture offset as second vector,
// and the texture rotation as float
llSetPrimitiveParams([PRIM_TEXTURE, 3, "4d304955-2b01-c6c6-f545-c1ae1e618288",
                          <1.0,1.0,0.0>, <0.0,0.0,0.0>, 0.0]);
// To set the prim "Full Bright" on sides 3
llSetPrimitiveParams([PRIM_FULLBRIGHT,3,TRUE]);
// And to make it all in one breath,
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <0.0,0.0,0.0>, 1.0,
                      PRIM_COLOR, 3, <1.0,1.0,1.0>, 1.0,
                      PRIM_TEXTURE, 3, "4d304955-2b01-c6c6-f545-c1ae1e618288",
                          <1.0,1.0,0.0>, <0.0,0.0,0.0>, 0.0,
                      PRIM_FULLBRIGHT, 3, TRUE]);
// And if you want to place it above your bed, to make you sleep well, and the coords
// of that place are, for example, <x, y, z>
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <0.0,0.0,0.0>, 1.0,
                      PRIM_COLOR, 3, <1.0,1.0,1.0>, 1.0,
                      PRIM_TEXTURE, 3, "4d304955-2b01-c6c6-f545-c1ae1e618288",
                          <1.0,1.0,0.0>, <0.0,0.0,0.0>,0.0,
                      PRIM_FULLBRIGHT, 3, TRUE,
                      PRIM_POSITION, <x, y, z>]);
// You can set the texture of several sides at once, with no time penalty,
// just by repeating the param for that:
llSetPrimitiveParams([
        PRIM_TEXTURE, 3, "4d304955-2b01-c6c6-f545-c1ae1e618288",
            <1.0,1.0,0.0>, <0.0,0.0,0.0>, 0.0,
        PRIM_TEXTURE, 4, "4d304955-2b01-c6c6-f545-c1ae1e618288",
            <1.0,1.0,0.0>, <0.0,0.0,0.0>, 0.0
    ]);
</lsl>
=== Top-size (taper) ===
<lsl>default
{
    state_entry()
    {
        vector XYZ = llGetScale();
        float X = XYZ.x;
        float Y = XYZ.y;   
        llSetPrimitiveParams([PRIM_SIZE, <X,Y,0.1>, // keep the prim thin
                              PRIM_TYPE, PRIM_TYPE_BOX, 0, <0.0,1.0,0.0>, 0.0, ZERO_VECTOR,
                              <1.0 - (0.4 / X), 1.0 - (0.4 / Y), 0.0>,
                              ZERO_VECTOR]); //We use the equation "answer = 1 - desired_taper"
        // The proportions of the top-size (taper) will be maintained (as close as possible)
        // whenever the prim is resized. The proportion above will produce a reasonably
        // pleasing picture frame kinda thing.
    }
    changed(integer change)
    {
        if(change & CHANGED_SCALE)
        {
            llResetScript();
        }
    }
}
</lsl>
|helpers=
<lsl> //-- PRIM_ROTATION workaround for child prims (works in unattached objects only)
llSetPrimitiveParams( [PRIM_ROT_LOCAL, rot * llGetRootRotation()] )
//-- PRIM_ROTATION workaround for child prims (works in linked objects only)
llSetPrimitiveParams( [PRIM_ROT_LOCAL, rot * llList2Rot( llGetLinkPrimitiveParams( LINK_ROOT, [PRIM_ROT_LOCAL] ), 0 )] )
//-- PRIM_ROTATION workaround for child prims (works in all scenarios)
llSetPrimitiveParams( [PRIM_ROT_LOCAL, rot * llList2Rot( llGetLinkPrimitiveParams( !!llGetLinkNumber(), [PRIM_ROT_LOCAL] ), 0 )] )</lsl>
|also_functions={{LSL DefineRow||[[llGetPrimitiveParams]]|Get many primitive parameters}}
{{LSL DefineRow||[[llSetLinkPrimitiveParams]]|Set parameters on other prims in linkset}}
{{LSL DefineRow||[[llGetLinkPrimitiveParams]]|Get many primitive parameters of other prims in likset}}
{{LSL DefineRow||[[llSetLinkPrimitiveParamsFast]]|Set parameters on other prims in linkset without sleep}}
{{LSL DefineRow||[[llSetAlpha]]|Simpler way to set alpha (transparency)}}
{{LSL DefineRow||[[llSetTexture]]|Simpler way to set texture}}
{{LSL DefineRow||[[llSetColor]]|Simpler way to set color}}
{{LSL DefineRow||[[llSetScale]]|Simpler way to set scale}}
{{LSL DefineRow||[[llSetStatus]]|Simpler way to set physics and phantom}}
|also_tests
|also_events
|also_articles
|notes=The old PRIM_TYPE interface (labeled PRIM_TYPE_LEGACY), while technically retired, can still be used.
|issues
|cat1=Prim
|cat2=Movement
|cat3=Status
|cat4=Texture
|cat5=Object
|cat6=PrimitiveParams
}}

Latest revision as of 23:34, 14 December 2013