This function sets environment values for an individual agent in an experience. The changes to the environment persist until the agent moves to a new region or llSetAgentEnvironment is called for an agent with an empty list. Passing an empty list in params will strip all environmental settings applied to this agent as part of the experience

Syntax

integer llSetAgentEnvironment( key agent_id, float transition, list params );

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.
list params
A list of parameters to retrieve from the current environment. See table below for details.

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_INVALID_RULE-5There was an issue with one of the rules.
ENV_VALIDATION_FAIL-6Unable to validate values passed.
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

float gTransitionTime = 3.0;
list gListEnvironmentParams = [
    SKY_CLOUD_TEXTURE, TEXTURE_PLYWOOD,
    SKY_GAMMA, 10.0,
    WATER_NORMAL_SCALE, <5.0, 5.0, 5.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 = llSetAgentEnvironment(agent_id, gTransitionTime, gListEnvironmentParams);
        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