Permissions
Some things a script can do affect an avatar directly: animating it, taking its controls, moving its camera, attaching to it, teleporting it or spending its owner’s money. Before a script may do any of these, an avatar has to grant it the matching runtime permission. These are separate from the permission masks on inventory items, which control copying, modifying and transferring.
A script asks with llRequestPermissions, and the answer arrives in the run_time_permissions event. Each permission is a bit in a script permission mask.
Concepts
- Permissions are flags combined with
|and requested together in one call- A script holds permissions from one avatar at a time; a new request replaces the previous grant
llGetPermissionsreturns the granted mask andllGetPermissionsKeythe avatar who granted it
- The avatar sees a dialog and can accept or decline
- Declining fires
run_time_permissionswith the declined bits missing, so always check the mask - Some permissions are granted without a dialog when the avatar is sitting on or wearing the object, such as
PERMISSION_TAKE_CONTROLS,PERMISSION_TRIGGER_ANIMATIONand the camera permissions
- Declining fires
- Some permissions can only be granted by the object’s owner, such as
PERMISSION_DEBIT,PERMISSION_CHANGE_LINKSandPERMISSION_ATTACH - Calling a function without its permission fails with a script error instead of acting
- Grants survive state changes but are cleared when the script resets
PERMISSION_CONTROL_CAMERAis revoked when the avatar stands up or detaches
- Experiences use
llRequestExperiencePermissionsinstead: an avatar accepts the experience once and later requests are granted silently
Functions and events
These are the functions and events for requesting and checking permissions.
llRequestPermissions(key agent, integer permissions) | |
event | run_time_permissions(integer perm) |
integer | llGetPermissions() |
key | llGetPermissionsKey() |
llRequestExperiencePermissions(key agent, string name) | |
event | experience_permissions(key agent_id) |
event | experience_permissions_denied(key agent_id, integer reason) |
Requesting permissions
Request in response to the avatar, from touch_start, attach or a sit in changed, and act once the grant arrives:
default{ touch_start(integer total_number) { llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION); }
run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) llStartAnimation("dance1"); }}Permissions
Section titled “Permissions”Scripting Details
Here are the functions and events in detail.
llRequestPermissions(key agent, integer permissions)Requests permissions (a bitfield specified by permissions) from the agent in the same region, calling run_time_permissions if granted. This call does not pause script execution. | |
event | run_time_permissions(integer perm)Triggered when an agent grants or denies runtime permissions requested by llRequestPermissions. Passes the active integer permissions bitfield perm (returns 0 if no permissions are currently granted). |
integer | llGetPermissions()Returns an integer bitfield representing the permissions (PERMISSION_*) currently granted to the script. |
key | llGetPermissionsKey()Returns the key (UUID) of the avatar that last granted or declined permissions to the script, or NULL_KEY if the permissions request was ignored or cancelled. |
llRequestExperiencePermissions(key agent, string name)Requests permission from the specified agent to participate in the experience. These permissions are persistent and apply grid-wide across all scripts in the experience, automatically triggering experience_permissions or experience_permissions_denied. | |
event | experience_permissions(key agent_id)Triggered when the agent specified by agent_id approves an experience permissions request (interactively or automatically if previously approved). |
event | experience_permissions_denied(key agent_id, integer reason)Triggered when the agent specified by agent_id denies experience permissions, or when permission is blocked for other reasons (specified by the error code reason). |
Constant groups ScriptPermission 13
Related
Section titled “Related”See also Feature ExperienceFeature MoneyFeature InputFeature AvatarsFeature CameraCategory PermissionsPlanned Recipe: animation and control HUD