The llReplaceAgentEnvironment function overrides the current region and parcel environment seen by an agent. The new environment persists until the agent crosses to a new region or this function is called with the NULL_KEY or empty string in the environment parameter for the particular agent, doing so will strip all environmental settings applied to this agent as part of the experience. This function must be executed as part of an experience.

Syntax

Integer llReplaceAgentEnvironment( key agent_id, float transition, string environment );

Parameters

key agent_id
The key for an agent in the region. The agent must be in the region and must be participating in the experience.
float transition
The number of seconds over which to transition to the new settings.
string environment
The name of an environmental setting in the object's inventory or the asset ID for an environment.

Return value

Returns an Integer

Constants

Return Values

ValueConstantDescription
1The agent has been instructed to change their environment.
ENV_NOT_EXPERIENCE-1The script is not running as part of an experience with a valid experience key.
ENV_NO_EXPERIENCE_PERMISSION-2The agent has not granted permission.
ENV_NO_ENVIRONMENT-3The environment inventory object could not be found.
ENV_INVALID_AGENT-4Unable to find specified agent.
ENV_NO_EXPERIENCE_LAND-7The experience has not been enabled or can not run on the land.
ENV_THROTTLE-8The scripts have exceeded the throttle. Wait and retry the request.

Caveats

Examples

string gEnvironment = "A-12AM"; // Can be asset's name in object's inventory or the asset ID
float gTransitionTime = 3.0;

default
{
    touch_start(integer total_number)
    {
        key person = llDetectedKey(0);
        if (llGetAgentSize(person) != ZERO_VECTOR)
        {
            llRequestExperiencePermissions(person, "");
        }
        else
        {
            llInstantMessage(person, "You need to be in the same region to change environment");
        }
    }

    experience_permissions(key agent_id)
    {
        integer envTest = llReplaceAgentEnvironment(agent_id, gTransitionTime, gEnvironment);
        if (envTest == 1)
        {
            llRegionSayTo(agent_id, 0, "Applying environment for " + (string)agent_id);
        }
        else
        {
            llRegionSayTo(agent_id, 0, "Cannot apply environment for " + (string)agent_id + " due to reason id: " + (string)envTest);
        }
    }

    experience_permissions_denied(key agent_id, integer reason)
    {
        llRegionSayTo(agent_id, 0, "Denied experience permissions for " + (string)agent_id + " due to reason id: " + (string)reason);
    }
}

See also

Functions