Difference between revisions of "User:Cerise Sorbet/Menu cross reference"

From Second Life Wiki
Jump to navigation Jump to search
m
m
Line 1: Line 1:
{{LSL Function
{{Issues/SVC-215}}{{Issues/SVC-4170}}{{Issues/SVC-3935}}{{LSL_Function/uuid|id|sim=*}}{{LSL_Function
|func_id=259|func_sleep=0.2|func_energy=10.0
|func_id=210|func_sleep=0.0|func_energy=10.0
|func=llSetPrimitiveParams|sort=SetPrimitiveParams
|sort=Key2Name|func=llKey2Name
|p1_type=list|p1_name=rules
|return_type=string|p1_type=key|p1_name=id
|func_desc=Sets the prims parameters according to '''rules'''.
|func_footnote='''id''' must specify a valid rezzed prim or avatar key, present in or otherwise known to the sim in which the script is running, otherwise an empty string is returned. In the case of an avatar, this function will still return a valid name if the avatar is a child agent of the sim (i.e., in an adjacent sim, but presently able to see into the one the script is in), or for a short period after the avatar leaves the sim (specifically, when the client completely disconnects from the sim, either as a main or child agent).<br /><br />
|func_footer=This is a very powerful & sharp function, each rule takes at least one parameter and has its own quirks. Each PRIM_* rule has its own dedicated article with specific information.
Keys of inventory items will not work; in the case of these, use [[llGetInventoryName]] instead.
|func_desc
|return_text=that is the {{LSLGC|Avatar/Name|legacy name}} of the prim or avatar specified by '''id'''.
|spec
|spec
|caveats=
|caveats=* It is difficult to tell the difference between a prim that has a name that is an empty string and a prim that is not in the sim, or because an invalid key was specified. Use [[llGetObjectDetails]] to avoid this problem.
*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 get around the "avatar must be present" limitation, you can use the [[llRequestAgentData]] function and the [[dataserver]] event to obtain the avatar's name from a key.
**To fix this replace the PRIM_TYPE flag with the value 1 or updated to the newer PRIM_TYPE syntax.
* There is no opposite function ([[llName2Key]]) available. However, there are third-party websites which can be queried using the [[llHTTPRequest]] function and the [[http_response]] event.
* [[PRIM_ROTATION]] is bugged in child prims, see [[llSetPrimitiveParams#Useful_Snippets|Useful Snippets]] for a workaround, or the linked SVC-93 issue below.
* If an avatar is "ghosted" (which occasionally happens due to a longstanding server bug), an empty string is returned even though the avatar is seemingly present and shows up in [[llSensor]] and the [[Mini-Map]]. This fact can be used as the basis of a [[Ghost Detector]] script.
* 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]]
|constants
|constants={{LSL Constants/PrimitiveParams|get}}
|examples=<lsl>// Best viewed in Chat History (ctrl-h)
|examples=<lsl>
default
// 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 you 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()
     collision_start(integer a)//Announce who collided
     {
     {
         vector XYZ = llGetScale();
         llSay(0, "llKey2Name: " + llKey2Name(llDetectedKey(0)) +
        float X = XYZ.x;
              "\nllDetectedName: " + llDetectedName(0));
        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)
     touch_start(integer a)
     {
     {
         if(change & CHANGED_SCALE)
         llSay(0,"llKey2Name: " + llKey2Name(llDetectedKey(0)) +
        {
              "\nllDetectedName: " + llDetectedName(0));
            llResetScript();
        }
     }
     }
}
}</lsl>
</lsl>
|helpers
|helpers=
|also_functions=
<lsl> //-- PRIM_ROTATION workaround for child prims (works in unattached objects only)
{{LSL DefineRow||[[llGetUsername]]}}
llSetPrimitiveParams( [PRIM_ROT_LOCAL, rot * llGetRootRotation()] )
{{LSL DefineRow||[[llGetDisplayName]]}}
{{LSL DefineRow||[[llGetObjectDetails]]}}
{{LSL DefineRow||[[llRequestAgentData]]|Uses the [[dataserver]] to request avatar information}}
|also_events
|also_articles=
{{LSL DefineRow||[[Prim Attribute Overloading]]}}
|also_tests
|notes='''Active Name2Key Databases:'''
*http://n2k.danardlabs.com (SSL, {{LSLGC|Legacy Name|Legacy Names}} & {{LSLGC|Username|Usernames}} supported)
*http://w-hat.com/name2key
*http://kdc.ethernia.net/sys/name2key.php
*http://wiki.apez.biz/Development (web-service API functions getAvatarKey and getAvatarName)
*http://insl.kubwa.de/name2key.php?name=name (Bot based name2key Database. Supports: {{LSLGC|Legacy Name|Legacy}} and {{LSLGC|Username}} formats)


//-- PRIM_ROTATION workaround for child prims (works in linked objects only)
'''Dead Name2Key Databases:'''
llSetPrimitiveParams( [PRIM_ROT_LOCAL, rot * llList2Rot( llGetLinkPrimitiveParams( LINK_ROOT, [PRIM_ROT_LOCAL] ), 0 )] )
*<s>http://www.libsecondlife.org/protocol/index.php/Name2key</s><font color=red>(Appears to be gone as of Apr 2008, but search for name2key on that site for more information)</font>
*<s>http://www.ulrikasheim.org/tools/name2key.html</s><font color=red>(Appears to be gone as of Apr 2008)</font>


//-- PRIM_ROTATION workaround for child prims (works in all scenarios)
'''Name2Key Libraries:'''
llSetPrimitiveParams( [PRIM_ROT_LOCAL, rot * llList2Rot( llGetLinkPrimitiveParams( !!llGetLinkNumber(), [PRIM_ROT_LOCAL] ), 0 )] )</lsl>
*[[Name2Key_in_LSL]]
|also_functions={{LSL DefineRow||[[llGetPrimitiveParams]]|Get many primitive parameters}}
*[[User:Ugleh_Ulrik/Name2Key|Ugleh Ulrik's Name2Key PHP script]]
{{LSL DefineRow||[[llSetLinkPrimitiveParams]]|Set parameters on other prims in linkset}}
|cat1=Avatar
{{LSL DefineRow||[[llGetLinkPrimitiveParams]]|Get many primitive parameters of other prims in likset}}
|cat2=Prim
{{LSL DefineRow||[[llSetLinkPrimitiveParamsFast]]|Set parameters on other prims in linkset without sleep}}
|cat3=Key
{{LSL DefineRow||[[llSetAlpha]]|Simpler way to set alpha (transparency)}}
|cat4=Avatar/Name
{{LSL DefineRow||[[llSetTexture]]|Simpler way to set texture}}
|cat5=Legacy Name
{{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
}}
}}

Revision as of 14:49, 16 December 2010

Summary

Function: string llKey2Name( key id );

Returns a string that is the legacy name of the prim or avatar specified by id.

• key id group, avatar or prim UUID that is in the same region

id must specify a valid rezzed prim or avatar key, present in or otherwise known to the sim in which the script is running, otherwise an empty string is returned. In the case of an avatar, this function will still return a valid name if the avatar is a child agent of the sim (i.e., in an adjacent sim, but presently able to see into the one the script is in), or for a short period after the avatar leaves the sim (specifically, when the client completely disconnects from the sim, either as a main or child agent).

Keys of inventory items will not work; in the case of these, use llGetInventoryName instead.

Caveats

  • It is difficult to tell the difference between a prim that has a name that is an empty string and a prim that is not in the sim, or because an invalid key was specified. Use llGetObjectDetails to avoid this problem.
  • To get around the "avatar must be present" limitation, you can use the llRequestAgentData function and the dataserver event to obtain the avatar's name from a key.
  • There is no opposite function (llName2Key) available. However, there are third-party websites which can be queried using the llHTTPRequest function and the http_response event.
  • If an avatar is "ghosted" (which occasionally happens due to a longstanding server bug), an empty string is returned even though the avatar is seemingly present and shows up in llSensor and the Mini-Map. This fact can be used as the basis of a Ghost Detector script.

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   llKey2Name returns text "(Loading...)" instead of empty string or avatar name

Examples

<lsl>// Best viewed in Chat History (ctrl-h) default {

   collision_start(integer a)//Announce who collided
   {
       llSay(0, "llKey2Name: " + llKey2Name(llDetectedKey(0)) +
              "\nllDetectedName: " + llDetectedName(0));
   }
   touch_start(integer a)
   {
       llSay(0,"llKey2Name: " + llKey2Name(llDetectedKey(0)) +
              "\nllDetectedName: " + llDetectedName(0));
   }
}</lsl>

Notes

Active Name2Key Databases:

Dead Name2Key Databases:

Name2Key Libraries:

See Also

Functions

•  llGetUsername
•  llGetDisplayName
•  llGetObjectDetails
•  llRequestAgentData Uses the dataserver to request avatar information

Articles

•  Prim Attribute Overloading

Deep Notes

All Issues

~ Search JIRA for related Issues
   llRequestAgentKey() (llName2Key())
   llKey2Name returns avatar names with double space between first and last (sometimes)
   llKey2Name returns text "(Loading...)" instead of empty string or avatar name

Signature

function string llKey2Name( key id );