Difference between revisions of "LlAttachToAvatarTemp"

From Second Life Wiki
Jump to: navigation, search
(intial version of translation in french)
(Make it more obvious that Temp works on other users.)
 
(15 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Multi-lang||/fr}}
+
{{LSL_Function
{{LSL_Function/fr
+
|inject-2={{Issues/SCR-395}}
|inject-2=
+
{{LSL_Function/permission|PERMISSION_ATTACH|temp=*}}
{{LSL_Function/fr/permission|PERMISSION_ATTACH|temp=*}}
+
 
|func = llAttachToAvatarTemp
 
|func = llAttachToAvatarTemp
|func_desc = suit les mêmes règles que [[llAttachToAvatar/fr|llAttachToAvatar]], à l'exeption près que l'objet ne sera pas créé dans l inventaire de l'avatar et disparaîtra à sa déconnexion ou au détachement de l objet. En effet , par design , cela permet de "redonner" plusieurs fois à un autre utilisateur un objet en tant qu attachement sans que cela pollue son inventaire.
+
|func_desc = Follows the same convention as [[llAttachToAvatar]], with the exception that the object will not create new inventory for the user, and will disappear on detach or disconnect. Also, this function can be used on avis other than the owner (if granted permission) in which case the ownership is changed to the new wearer.
|func_footnote = On doit considérer cet objet comme un attachement temporaire ; un utilisateur ne peut pas utiliser les actions "prendre" , "prendre une copie" sur celui ci.
+
|func_footnote = It should be noted that when an object is attached temporarily, a user cannot 'take' or 'drop' the object that is attached to them.
* D'autre part, le grand avantage de cette fonction est que l'utilisateur  n'a pas besoin d'être le propriétaire de l objet pour pouvoir l'attacher.  
+
The user does not have to be the owner of the object in advance; this function transfers ownership automatically (the usual permissions required to transfer objects apply).
En revanche, les permissions du script sont à réinitialiser pour le"propriétaire à titre temporaire".  
+
 
|p1_type = integer
 
|p1_type = integer
 +
|p1_subtype = attach_point
 
|p1_name = attach_point
 
|p1_name = attach_point
|p1_desc = ATTACH_* constante ( voir table ci-dessous )
+
|p1_desc = ATTACH_* constant or valid value (see the tables below)
|constants = {{LSL_Constants_Attachment/fr}}
+
|constants = {{LSL_Constants_Attachment}}
 
|caveats =
 
|caveats =
* Toutes les permissions du script sont à réinitialiser lors de l 'attachement de l'objet temporaire ( probablement pour des mesures de sécurité)
+
* When object ownership changes, any granted permissions are reset. After a successful attach, you will need a fresh call to [[llRequestPermissions]] to allow [[llDetachFromAvatar]] and other permission-required functions to work.
* L utilisation de llAttachToAvatarTemp sur un objet que vous n avez pas la permission de transférer provoquera une erreur de script ''No permission to transfer'', même si vous l'attachez à vous mêmes ( il faut voir cette fonction comme un transfert)
+
** Until successful attachment via this method, previously granted permissions are retained as normal.
* Les points d'attachements peuvent être occupés par plusieurs  objets.
+
* The attach step is not guaranteed to succeed, and this function should not be relied on as a security measure. Use the same permission and script precautions you would use with conventional inventory transfers.
* Si {{LSLP|attach_point}} est zéro , il se retrouve attaché par défaut à la main droite ({{LSL Const/fr|ATTACH_RHAND|integer|6|c=right hand}}).
+
* If you use llAttachToAvatarTemp in an object that you do not have permission to transfer, the function will fail with a script error ''No permission to transfer'', even if you are trying to attach it to yourself.
* Si l'objet est déjà attaché , la fonction ne fait rien silencieusement , même si le point d'attachement est différent .
+
* Temporary attachments cannot request the permission [[PERMISSION_TELEPORT]], the following error will be returned: ''"Temporary attachments cannot request runtime permissions to teleport"''
|examples = <lsl>// exemple basique qui ne fait rien d intéressant mais qui illustre son fonctionnement
+
*Attach points can be occupied by multiple attachments.{{Footnote|Multiple attachments per attach point were added as result of {{Jira|SCR-277}}|Multiple attachments per attach point were added as result of SCR-277}}
 +
**This was not always the case, previously if {{LSLP|attach_point}} was occupied, the existing object was detached and the new attachment took it's place.  
 +
*Objects attached to the head (and any attachment position within the head) will not be visible in First Person view (aka [[Mouselook]]) if "show attachments in mouselook" is disabled.
 +
*If {{LSLP|attach_point}} is zero but the object was never previously attached, it defaults to the right hand ({{LSL Const|ATTACH_RHAND|integer|6|c=right hand}}).
 +
*If the object is already attached the function fails silently, regardless if the {{LSLP|attach_point}} is a different {{LSLGC|Integer/attach_point|attach point}}.
 +
*If attached via a Land Scope Experience script, the object will be forced detached by the server if the owner enters a parcel that does not have the Experience allowed.
 +
*If the target agent is already wearing the maximum number of attachments, the object will remain on the ground with the target agent as owner. Scripters may wish to check for successful attachment and llDie() after a timeout or if the object is manipulated while unattached.
 +
|examples = <source lang="lsl2">//-- rez object on ground, drop in this script, it will request permissions to attach,
 +
//-- and then attach to the left hand if permission is granted. if permission is denied,
 +
//-- then the script complains.
 
default
 
default
 
{
 
{
Line 58: Line 66:
 
         }
 
         }
 
     }
 
     }
}</lsl>
+
}</source>
  
<lsl>//-- Cet exemple démontre le transfert de propriété d un objet temporaire attaché via llAttachToAvatarTemp()
+
<source lang="lsl2">//-- This example can demonstrate ownership transfer of an object on a temporary basis using llAttachToAvatarTemp()
//-- Quelque soit la personne qui touche l objet , aura  l objet attaché sous réserve quj il accepte les permissions qu on lui demande
+
//-- Whoever touches will be asked for permission to attach, and upon granting permission will have the item attach,
//-- Mais l'objet attaché n’apparaîtra pas dans l'inventaire.
+
//-- But not appear in Inventory.
 
default
 
default
 
{
 
{
Line 89: Line 97:
 
         }
 
         }
 
     }
 
     }
}</lsl>
+
}</source>
  
<lsl>// Cet exemple illustre comment gèrer les permissions après l'appel à llAttachToAvatarTemp.  
+
<source lang="lsl2">// This example illustrates how to handle permissions before and after llAttachToAvatarTemp has been called. Because ownership
// Parce que le proprétaire a changé , la permission initiale PERMISSION_ATTACH est révoquée et de nouvelles permissions ont besoin d'être demandées .
+
// changes when the object is attached, the initial PERMISSION_ATTACH is revoked and new permissions need to be requested.
// Une façon de procéder sans que l'utilisateur soit ennuyé par une autre boite de dialogue pour demander les permissions est de
+
// demander de nouvelles permissions lors de l attachement à l avatar .
+
// Et utiliser ainsi , les permissions automatiques accordées pour les objets attachés .
+
  
 
integer gAttach = TRUE;
 
integer gAttach = TRUE;
Line 104: Line 109:
 
     touch_start(integer num)
 
     touch_start(integer num)
 
     {
 
     {
         if (gAttach)  // l'objet n' a pas déjà été attaché
+
         if (gAttach)  // Object has not been attached yet
 
         {
 
         {
 
             llRequestPermissions(llDetectedKey(0),PERMISSION_ATTACH);
 
             llRequestPermissions(llDetectedKey(0),PERMISSION_ATTACH);
 
             gAttach = FALSE;
 
             gAttach = FALSE;
 
         }
 
         }
         else  // L'objet a été attaché , on vérifie les permissions PERMISSION_ATTACH puis on le détache
+
         else  // Object has been attached, but you still need PERMISSION_ATTACH in order to detach the object
 
         {
 
         {
 
             if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH)
 
             if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH)
 
             {
 
             {
                 llDetachFromAvatar();  // Notez que l'objet disparait lors du détachement. Il n y a donc pas besoin de mettre  gAttach = TRUE  
+
                 llDetachFromAvatar();  // Note that the object vanishes when detached, so there is no need to set gAttach = TRUE again
 
             }
 
             }
 
         }
 
         }
Line 120: Line 125:
 
     attach(key id)
 
     attach(key id)
 
     {
 
     {
         if (id)  //L objet vient juste d être attaché ; mais on aura besoin des permissions PERMISSION_ATTACH  pour pouvoir le détacher . Or comme les permissions sont réinitialisées à cause  du transfert d objet , on doit redemander les permissions . Dans ce cas , on utilise les permissions automatiques accordées pour les objets attachés , et la requête est automatiquement acceptée sans que l utilisateur reclique une seconde fois sur une
+
         if (id)  // Object has been attached, so request permissions again
boite de dialogue de permissions
+
 
         {
 
         {
 
             llRequestPermissions(id,PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);
 
             llRequestPermissions(id,PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);
Line 129: Line 133:
 
     run_time_permissions (integer perm)
 
     run_time_permissions (integer perm)
 
     {
 
     {
         if (!gAttach)  // première fois
+
         if (!gAttach)  //First time
 
         {
 
         {
 
             if (perm & PERMISSION_ATTACH)
 
             if (perm & PERMISSION_ATTACH)
 
             {
 
             {
 
                 gAttach = TRUE;
 
                 gAttach = TRUE;
                 llAttachToAvatarTemp(ATTACH_HEAD);  // Initial PERMISSION_ATTACH est révoqué à cette ligne du script.
+
                 llAttachToAvatarTemp(ATTACH_HEAD);  // Initial PERMISSION_ATTACH is revoked at this point
 
             }
 
             }
 
         }
 
         }
         else  // seconde fois
+
         else  // Second time
 
         {
 
         {
 
             if (perm & PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION)
 
             if (perm & PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION)
Line 145: Line 149:
 
         }
 
         }
 
     }
 
     }
}</lsl>
+
}</source>
Une autre solution :
+
An alternative solution:
<lsl>
+
<source lang="lsl2">
 +
// Because ownership changes when the object is attached, the initial PERMISSION_ATTACH is revoked and new permissions need to be requested.
  
 
default
 
default
Line 165: Line 170:
 
         if (perm & PERMISSION_TRIGGER_ANIMATION) llStartAnimation( llGetInventoryName( INVENTORY_ANIMATION, 0));
 
         if (perm & PERMISSION_TRIGGER_ANIMATION) llStartAnimation( llGetInventoryName( INVENTORY_ANIMATION, 0));
 
     }
 
     }
}</lsl>
+
}</source>
  
|also_functions = {{LSL DefineRow||[[llDetachFromAvatar/fr|llDetachFromAvatar]]|Détache un objet de l'avatar}}
+
|also_functions = {{LSL DefineRow||[[llDetachFromAvatar]]|Detaches the object from the avatar}}
{{LSL DefineRow||[[llGetAttached/fr|llGetAttached]]|Retourne le numéro du point attachement}}
+
{{LSL DefineRow||[[llGetAttached]]|Gets the attach point number}}
 
|cat1 = Attachment
 
|cat1 = Attachment
 
|cat2 = Avatar
 
|cat2 = Avatar
|history = Date de Release  [[ Release_Notes/Second_Life_Server/12#12.07.24.262437 | 24/07/2012 ]]
+
|history = Date of Release  [[ Release_Notes/Second_Life_Server/12#12.07.24.262437 | 24/07/2012 ]]
 +
|haiku={{Haiku|Embrace me. I'm yours|If only for a short time|Rejected, we part.}}
 
}}
 
}}

Latest revision as of 15:26, 10 August 2017

Summary

Function: llAttachToAvatarTemp( integer attach_point );

Follows the same convention as llAttachToAvatar, with the exception that the object will not create new inventory for the user, and will disappear on detach or disconnect. Also, this function can be used on avis other than the owner (if granted permission) in which case the ownership is changed to the new wearer.

• integer attach_point ATTACH_* constant or valid value (see the tables below)

To run this function the script must request the PERMISSION_ATTACH permission with llRequestPermissions. It should be noted that when an object is attached temporarily, a user cannot 'take' or 'drop' the object that is attached to them. The user does not have to be the owner of the object in advance; this function transfers ownership automatically (the usual permissions required to transfer objects apply).

KBnote.png Note: Constants in italic require a viewer compatible with the Project Bento skeleton.
Body
Constant # Name Comment
ATTACH_HEAD 2 Skull head
ATTACH_NOSE 17 Nose nose
ATTACH_MOUTH 11 Mouth mouth
ATTACH_FACE_TONGUE 52 Tongue tongue
ATTACH_CHIN 12 Chin chin
ATTACH_FACE_JAW 47 Jaw jaw
ATTACH_LEAR 13 Left Ear left ear
ATTACH_REAR 14 Right Ear right ear
ATTACH_FACE_LEAR 48 Alt Left Ear left ear (extended)
ATTACH_FACE_REAR 49 Alt Right Ear right ear (extended)
ATTACH_LEYE 15 Left Eye left eye
ATTACH_REYE 16 Right Eye right eye
ATTACH_FACE_LEYE 50 Alt Left Eye left eye (extended)
ATTACH_FACE_REYE 51 Alt Right Eye right eye (extended)
ATTACH_NECK 39 Neck neck
ATTACH_LSHOULDER 3 Left Shoulder left shoulder
ATTACH_RSHOULDER 4 Right Shoulder right shoulder
ATTACH_LUARM 20 L Upper Arm left upper arm
ATTACH_RUARM 18 R Upper Arm right upper arm
ATTACH_LLARM 21 L Lower Arm left lower arm
ATTACH_RLARM 19 R Lower Arm right lower arm
ATTACH_LHAND 5 Left Hand left hand
ATTACH_RHAND 6 Right Hand right hand
ATTACH_LHAND_RING1 41 Left Ring Finger left ring finger
ATTACH_RHAND_RING1 42 Right Ring Finger right ring finger
ATTACH_LWING 45 Left Wing left wing
ATTACH_RWING 46 Right Wing right wing
ATTACH_CHEST 1 Chest chest/sternum
ATTACH_LEFT_PEC 29 Left Pec left pectoral
ATTACH_RIGHT_PEC 30 Right Pec right pectoral
ATTACH_BELLY 28 Stomach belly/stomach/tummy
ATTACH_BACK 9 Spine back
ATTACH_TAIL_BASE 43 Tail Base tail base
ATTACH_TAIL_TIP 44 Tail Tip tail tip
ATTACH_AVATAR_CENTER 40 Avatar Center avatar center/root
ATTACH_PELVIS 10 Pelvis pelvis
ATTACH_GROIN 53 Groin groin
ATTACH_LHIP 25 Left Hip left hip
ATTACH_RHIP 22 Right Hip right hip
ATTACH_LULEG 26 L Upper Leg left upper leg
ATTACH_RULEG 23 R Upper Leg right upper leg
ATTACH_RLLEG 24 R Lower Leg right lower leg
ATTACH_LLLEG 27 L Lower Leg left lower leg
ATTACH_LFOOT 7 Left Foot left foot
ATTACH_RFOOT 8 Right Foot right foot
ATTACH_HIND_LFOOT 54 Left Hind Foot left hind foot
ATTACH_HIND_RFOOT 55 Right Hind Foot right hind foot
HUD
Constant Comment
ATTACH_HUD_CENTER_2 31 HUD Center 2
ATTACH_HUD_TOP_RIGHT 32 HUD Top Right
ATTACH_HUD_TOP_CENTER 33 HUD Top
ATTACH_HUD_TOP_LEFT 34 HUD Top Left
ATTACH_HUD_CENTER_1 35 HUD Center
ATTACH_HUD_BOTTOM_LEFT 36 HUD Bottom Left
ATTACH_HUD_BOTTOM 37 HUD Bottom
ATTACH_HUD_BOTTOM_RIGHT 38 HUD Bottom Right

Caveats

Permissions
  • Do not depend upon the auto-grant status of permissions. Always use the run_time_permissions event.
  • If the script lacks the permission PERMISSION_ATTACH, the script will shout an error on DEBUG_CHANNEL and the operation fails (but the script continues to run).
  • Once the PERMISSION_ATTACH permission is granted there is no way to revoke it except from inside the script (for example, with a new llRequestPermissions call) or the script is reset or deleted.
  • When object ownership changes, any granted permissions are reset. After a successful attach, you will need a fresh call to llRequestPermissions to allow llDetachFromAvatar and other permission-required functions to work.
    • Until successful attachment via this method, previously granted permissions are retained as normal.
  • The attach step is not guaranteed to succeed, and this function should not be relied on as a security measure. Use the same permission and script precautions you would use with conventional inventory transfers.
  • If you use llAttachToAvatarTemp in an object that you do not have permission to transfer, the function will fail with a script error No permission to transfer, even if you are trying to attach it to yourself.
  • Temporary attachments cannot request the permission PERMISSION_TELEPORT, the following error will be returned: "Temporary attachments cannot request runtime permissions to teleport"
  • Attach points can be occupied by multiple attachments.[1]
    • This was not always the case, previously if attach_point was occupied, the existing object was detached and the new attachment took it's place.
  • Objects attached to the head (and any attachment position within the head) will not be visible in First Person view (aka Mouselook) if "show attachments in mouselook" is disabled.
  • If attach_point is zero but the object was never previously attached, it defaults to the right hand (ATTACH_RHAND).
  • If the object is already attached the function fails silently, regardless if the attach_point is a different attach point.
  • If attached via a Land Scope Experience script, the object will be forced detached by the server if the owner enters a parcel that does not have the Experience allowed.
  • If the target agent is already wearing the maximum number of attachments, the object will remain on the ground with the target agent as owner. Scripters may wish to check for successful attachment and llDie() after a timeout or if the object is manipulated while unattached.

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   llAttachToAvatarTemp worn objects do not keep group name.

Examples

//-- rez object on ground, drop in this script, it will request permissions to attach,
//-- and then attach to the left hand if permission is granted. if permission is denied,
//-- then the script complains.
default
{
    state_entry()
    {
        llRequestPermissions( llGetOwner(), PERMISSION_ATTACH );
    }
 
    run_time_permissions( integer vBitPermissions )
    {
        if( vBitPermissions & PERMISSION_ATTACH )
        {
            llAttachToAvatarTemp( ATTACH_LHAND );
        }
        else
        {
            llOwnerSay( "Permission to attach denied" );
        }
    }
 
    on_rez(integer rez)
    {
        if(!llGetAttached())
        { //reset the script if it's not attached.
            llResetScript();
        }
    }
 
    attach(key AvatarKey)
    {
        if(AvatarKey)
        {//event is called on both attach and detach, but Key is only valid on attach
            integer test = llGetAttached();
            if (test) {
                llOwnerSay( "The object is attached" );
            } else {
                llOwnerSay( "The object is not attached");
            }
        }
    }
}
//-- This example can demonstrate ownership transfer of an object on a temporary basis using llAttachToAvatarTemp()
//-- Whoever touches will be asked for permission to attach, and upon granting permission will have the item attach,
//-- But not appear in Inventory.
default
{
    touch_start(integer num_touches)
    {
        llRequestPermissions( llDetectedKey(0), PERMISSION_ATTACH );
    }
 
    run_time_permissions( integer vBitPermissions )
    {
        if( vBitPermissions & PERMISSION_ATTACH )
        {
            llAttachToAvatarTemp( ATTACH_LHAND );
        }
        else
        {
            llOwnerSay( "Permission to attach denied" );
        }
    }
 
    on_rez(integer rez)
    {
        if(!llGetAttached())
        { //reset the script if it's not attached.
            llResetScript();
        }
    }
}
// This example illustrates how to handle permissions before and after llAttachToAvatarTemp has been called. Because ownership
// changes when the object is attached, the initial PERMISSION_ATTACH is revoked and new permissions need to be requested.
 
integer gAttach = TRUE;
 
default
{
 
    touch_start(integer num)
    {
        if (gAttach)  // Object has not been attached yet
        {
            llRequestPermissions(llDetectedKey(0),PERMISSION_ATTACH);
            gAttach = FALSE;
        }
        else   // Object has been attached, but you still need PERMISSION_ATTACH in order to detach the object
        {
            if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION | PERMISSION_ATTACH)
            {
                llDetachFromAvatar();  // Note that the object vanishes when detached, so there is no need to set gAttach = TRUE again
            }
        }
    }
 
    attach(key id)
    {
        if (id)  // Object has been attached, so request permissions again
        {
            llRequestPermissions(id,PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);
        }
    }
 
    run_time_permissions (integer perm)
    {
        if (!gAttach)  //First time
        {
            if (perm & PERMISSION_ATTACH)
            {
                gAttach = TRUE;
                llAttachToAvatarTemp(ATTACH_HEAD);  // Initial PERMISSION_ATTACH is revoked at this point
            }
        }
        else  // Second time
        {
            if (perm & PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION)
            {
                llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));
            }
        }
    }
}

An alternative solution:

// Because ownership changes when the object is attached, the initial PERMISSION_ATTACH is revoked and new permissions need to be requested.
 
default
{
    touch_start(integer num)
    {
        if (!llGetAttached()) llRequestPermissions( llDetectedKey(0), PERMISSION_ATTACH);
        else if ( llGetPermissions() & PERMISSION_ATTACH) llDetachFromAvatar();
    }
    attach(key id)
    {
        if (id) llRequestPermissions( id, PERMISSION_ATTACH | PERMISSION_TRIGGER_ANIMATION);
    }
    run_time_permissions (integer perm)
    {
        if (!llGetAttached() && (perm & PERMISSION_ATTACH)) llAttachToAvatarTemp( ATTACH_NOSE);
        if (perm & PERMISSION_TRIGGER_ANIMATION) llStartAnimation( llGetInventoryName( INVENTORY_ANIMATION, 0));
    }
}

See Also

Events

•  run_time_permissions Permission receiving event

Functions

•  llGetPermissions Get the permissions granted
•  llGetPermissionsKey Get the agent who granted permissions
•  llRequestPermissions Request permissions
•  llDetachFromAvatar Detaches the object from the avatar
•  llGetAttached Gets the attach point number

Articles

•  Script permissions

Deep Notes

History

Date of Release 24/07/2012

All Issues

~ Search JIRA for related Issues
   llAttachToAvatarTemp worn objects do not keep group name.

Footnotes

  1. ^ Multiple attachments per attach point were added as result of SCR-277

Signature

function void llAttachToAvatarTemp( integer attach_point );

Haiku

Embrace me. I'm yours
If only for a short time
Rejected, we part.