Skip to content
lsl.devlsl.devLSL Dev

Experience

An experience groups scripts under one identity. An avatar accepts the experience once, and from then on its scripts can animate, teleport, attach to or take controls from that avatar without asking again, wherever the experience is allowed.

Scripts join an experience when they are compiled with it selected. Experiences also bring a shared key-value store and abilities that ordinary scripts do not have.

Experience scripts use the same events and permission flow as ordinary scripts: llRequestExperiencePermissions takes the place of the per-object prompt.

Concepts

Functions and events

voidllRequestExperiencePermissions(key agent, string name)
eventexperience_permissions(key agent_id)
eventexperience_permissions_denied(key agent_id, integer reason)
integerllAgentInExperience(key agent)
listllGetExperienceDetails(key experience_id)
keyllReadKeyValue(string k)
keyllUpdateKeyValue(string k, string v, integer checked, string original_value)
integerllSitOnLink(key agent_id, integer link)

Experience Tools

The archived wiki category for experience tools and the functions that use them.

Key-value store

Each call returns a query key; match it in dataserver to read the result.

Scripting Details

voidllRequestExperiencePermissions(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.
eventexperience_permissions(key agent_id)
Triggered when the agent specified by agent_id approves an experience permissions request (interactively or automatically if previously approved).
eventexperience_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).
integerllAgentInExperience(key agent)
Returns TRUE if the specified agent is in the experience and the experience can run in the current region/location; returns FALSE otherwise.
integerllGetPermissions()
Returns an integer bitfield representing the permissions (PERMISSION_*) currently granted to the script.
listllGetExperienceDetails(key experience_id)
Returns a list of details for the specified experience_id, formatted as [string experience_name, key owner_id, key experience_id, integer state, string state_message, key group_id].
stringllGetExperienceErrorMessage(integer error)
Returns a text description of the specified experience error code, or a description of XP_ERROR_UNKNOWN_ERROR if the error is invalid.
integerllSitOnLink(key agent_id, integer link)
Forces the avatar specified by agent_id (who must be participating in the experience) to sit on the sit target of the prim indicated by link. If occupied, searches down the linkset for an available sit target. Returns an integer.
voidllAttachToAvatarTemp(integer attach_point)
Attaches the object temporarily to an avatar who has granted the PERMISSION_ATTACH permission. No permanent inventory is created, and the object disappears on detach or disconnect. Can be used on non-owners (changing ownership to the wearer).
integerllReplaceAgentEnvironment(key agent_id, float transition, string environment)
Replaces the region and parcel environment seen by the specified agent_id as part of an experience, transitioning the settings over transition seconds. Passing NULL_KEY or an empty string for environment restores defaults.
integerllSetAgentEnvironment(key agent_id, float transition, list params)
Sets an individual agent's environmental settings using the attributes in params over a duration of transition seconds. Must be used as part of an experience; passing an empty list removes overrides.
voidllTeleportAgent(key agent, string landmark, vector position, vector look_at)
Teleports the owning agent (who must grant PERMISSION_TELEPORT) to a landmark in the object's inventory. If landmark is empty, teleports them to position within the current region. Upon arrival, the agent is turned to face look_at. Can only teleport the owner.

Additional

Constant groups ScriptPermission 13ExperienceError 19

See also Feature Data StorageCategory Experience Data

See also Feature AvatarsFeature EnvironmentsSL Wiki Experience ToolsSL Wiki LSL ExperiencePlanned Guide: creating an experience and compiling scripts to it