LlRequestPermissions
From Second Life Wiki
(Redirected from LSL llRequestPermissions)
| LSL Portal | | | Functions | | | Events | | | Types | | | Operators | | | Constants | | | Flow Control | | | Script Library | | | Tutorials |
Contents |
Description
Function: llRequestPermissions( key agent, integer perm );| 136 | Function ID |
| 0.0 | Delay |
| 10.0 | Energy |
Ask agent for permission to run certain classes of functions.
| • key | agent | – | avatar UUID that is in the same region | |
| • integer | perm | – | Permission mask (bitfield containing the permissions to request). |
| Constants | Action | Category | Granter | |
|---|---|---|---|---|
| PERMISSION_DEBIT | 0x2 | take money from agent's account | Money | Owner |
| PERMISSION_TAKE_CONTROLS | 0x4 | take agent's controls | Control | Anyone |
| PERMISSION_TRIGGER_ANIMATION | 0x10 | trigger Animation on agent | Animation | Anyone |
| PERMISSION_ATTACH | 0x20 | attach/detach from agent | Attachment | Owner |
| PERMISSION_CHANGE_LINKS | 0x80 | change links | Link | Owner |
| PERMISSION_TRACK_CAMERA | 0x400 | track the agent's camera position and rotation | Camera | Anyone |
| PERMISSION_CONTROL_CAMERA | 0x800 | control the agent's camera | Camera | Anyone |
Caveats
- Permissions do not accumulate.
- If a permission was requested with a previous call to this function and granted, then in subsequent call was not requested, that permission is released (lost).
- To request two (or more) different permissions at the same time you can using the bitwise OR (|):
llRequestPermissions(AvatarID, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION)
- Scripts may hold permissions for only one agent at a time. To hold permissions for multiple agents you must use more then one script.
Examples
Request permission to animate an avatar
default { touch_start(integer detected) { llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION); } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { llStartAnimation("sit"); llOwnerSay("animation will end in 5 seconds"); llSetTimerEvent(5.0); } } timer() { llSetTimerEvent(0.0); llStopAnimation("sit"); } }
To request two (or more) different permissions at the same time you can using the bitwise OR (|) or precompute the value.
llRequestPermissions(AvatarID, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION); integer perms = PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION; llRequestPermissions(AvatarID, perms);
Notes
A dialog is presented to the agent to grant these permissions except for a few cases:
- If agent is sitting on object - Control and Camera tracking permissions are granted without notification upon request.
- If object is attached to agent - Control, Attach, and Animate permissions are granted without notification upon request so long as the script is in the root prim. If the script is not in the root prim, the user will see the confirmation dialog.
- Permissions can persist across state changes - You do not need to request permissions in the state_entry() of each state in your script.
Regardless if a dialog is displayed you should always use the run_time_permissions event instead of depending upon this quirk.
See Also
Events
| • | run_time_permissions | – | Permission receiver event |
Functions
| • | llGetPermissions | – | Get the permissions granted | |
| • | llGetPermissionsKey | – | Get the avatar who granted permissions. |
Articles
| • | Script permissions |

