Skip to content
lsl.devlsl.devLSL Dev

llSetAgentEnvironment

functionRequires an experience
Function syntax
integer llSetAgentEnvironment(
  1. key agent_id,// UUID of the agent participating in the experience.
  2. float transition,// Transition duration in seconds.
  3. list params// A list of environmental parameters to apply.
);
Returns
integer
Energy
10

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

How to use
integer result = llSetAgentEnvironment(NULL_KEY, 0.0, []);
From the LSL definitions: EnvironmentParam (rule, then its arguments)
// Sun, moon and starsSKY_SUN, rotation rot, float scale, vector sun_colorSKY_MOON, rotation rot, float scale, float brightnessSKY_SUN_TEXTURE, string texture_ident  // inventory name or UUIDSKY_MOON_TEXTURE, string texture_ident  // inventory name or UUIDSKY_GLOW, float glow_size, float glow_focusSKY_STAR_BRIGHTNESS, float brightness  // 0 to 500// Sky colour and atmosphereSKY_AMBIENT, vector colorSKY_BLUE, vector blue_density, vector blue_horizonSKY_HAZE, float density, float horizon, float density_multiplier, float distance_multiplierSKY_GAMMA, float gamma  // 0 to 20SKY_DOME, float offset, float radius, float max_altitudeSKY_PLANET, float planet_radius, float sky_bottom_radius, float sky_top_radiusSKY_REFRACTION, float moisture_level, float droplet_radius, float ice_levelSKY_REFLECTION_PROBE_AMBIANCE, float ambiance  // 0.0 to 10.0// CloudsSKY_CLOUDS, vector color, float coverage, float scale, float variance, vector scroll, vector density, vector detailSKY_CLOUD_TEXTURE, string texture_ident  // inventory name or UUID// WaterWATER_FOG, vector color, float density, float modulationWATER_NORMAL_TEXTURE, string texture_ident  // inventory name or UUIDWATER_NORMAL_SCALE, vector scale  // <0,0,0> to <10,10,10>WATER_WAVE_DIRECTION, vector large_wave, vector small_waveWATER_FRESNEL, float offset, float scaleWATER_REFRACTION, float scale_above, float scale_belowWATER_BLUR_MULTIPLIER, float multiplier  // -0.5 to 0.5

Return Values

ValueConstantDescription
ENV_OK1The 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.
parameterinteger valuevalues to setdescription
SKY_CLOUDS, vector color, float coverage, float scale, float variance, vector scroll, vector density, vector detail, integer is_default2vector color, float coverage, float scale, float variance, vector scroll, vector density, vector detail

Environmental cloud information:

  • color: The color used for the clouds.

    range = [<0,0,0>, <1,1,1>]

  • coverage: The coverage percentage.

    range = [0, 1]

  • scale: The scaling applied to the cloud textures.

    range = (0 - 3]

  • variance: A randomizing factor applied to the main cloud layer.

    range = [0, 1]

  • scroll: The scroll speed of the clouds. X is east/west, Y is north/south, and Z is unused.

    range = [<-50,-50>, <50,50>]

  • density: The X/Y and D parameter used to generate cloud density.

    range = [<0,0,0>, <1,1,3>]

  • detail: The X/Y and D parameter used to generate cloud details.

    range = [<0,0,0>, <1,1,1>]

SKY_CLOUD_TEXTURE19string texture_identName of item in inventory or UUID for texture to be used for the clouds.
SKY_DOME, float offset, float radius, float max_altitude4float offset, float radius, float max_altitude

Sky dome information.

  • offset: offset applied to the sky dome.

    range = [0,1]

  • radius: radius of the sky dome.

    range = [1000,2000]

  • max_altitude: altitude of the sky dome.

    range = [0,10000]

SKY_GAMMA5float gammaThe gamma value applied to the scene.
range = [0,20]
SKY_GLOW, float glow_size, float glow_focus6float glow_size, float glow_focus

Glow applied to the sun and moon.

  • glow_size: size of glow effect.

    range = [0.2, 40]

  • glow_focus: focus of glow effect.

    Range [-10, 10]

SKY_MOON, rotation rot, float scale, float brightness, integer is_default_texture, vector direction, vector ambient_color, vector diffuse_color9rotation rot, float scale, float brightness

Detailed moon information:

  • rot: The current rotation applied to the moon.

    Normalized rotation.

  • scale: The current scale applied to the moon’s texture.

    range = [0.25, 20]

  • brightness: The moon’s brightness.

    range = [0,1]

SKY_MOON_TEXTURE20string texture_identName of texture in inventory or UUID for texture to be used for the moon.
SKY_STAR_BRIGHTNESS13float brightnessBrightness value applied to stars.
range = [0,500]
SKY_SUN, rotation rot, float scale, vector sun_color, integer is_default_texture, vector direction, vector ambient_color, vector diffuse_color14rotation rot, float scale, vector sun_color

Detailed sun information:

  • rot: The current rotation applied to the sun.

    Normalized rotation.

  • scale: The current scale applied to the sun’s texture.

    range = [0.25, 20]

  • sun_color: The sun’s color.

    range = [<0,0,0>, <1,1,1>]

SKY_SUN_TEXTURE21string texture_identName of texture in inventory or UUID for texture to be used for the sun.
SKY_PLANET, float planet_radius, float sky_bottom_radius, float sky_top_radius10float planet_radius, float sky_bottom_radius, float sky_top_radius

Planet information used in rendering the sky.

  • planet_radius: range = [1000, 32768]
  • sky_bottom_radius: range = [1000, 32768]
  • sky_top_radius: range = [1000, 32768]
SKY_REFRACTION, float moisture_level, float droplet_radius, float ice_level11float moisture_level, float droplet_radius, float ice_level

Sky refraction parameters for rainbows and optical effects.

  • moisture_level: range = [0, 1]
  • droplet_radius: range = [5, 1000]
  • ice_level: range = [0, 1]
WATER_BLUR_MULTIPLIER100float multiplierMultiplier applied to blur the scene when under water. range = [-0.5, 0.5]
WATER_FOG, vector color, float density, float modulation101vector color, float density, fload modulation

Fog parameters applied when underwater:

  • color: The color of the underwater fog.

    range = [<0,0,0>, <1,1,1>]

  • density: Density exponent applied to the fog.

    range = [-10, 10]

  • modulation:

    range = [0, 20]

WATER_FRESNEL, float offset, float scale102float offset, float scale

Fresnel scattering applied to the surface of the water.

  • offset: range = [0,1]

scale: range = [0,1]

WATER_NORMAL_TEXTURE107string texture_identName of texture in inventory or UUID of texture to be used for the water normal.
WATER_NORMAL_SCALE104vector scaleScaling applied to the water normal map. range = [<0,0,0>, <10,10,10>]
WATER_REFRACTION, float scale_above, float scale_below105float scale_above, float scale_below

Refraction factors when looking through the surface of the water.

  • scale_above: range = [0, 3]
  • scale_below: range = [0, 3]
WATER_WAVE_DIRECTION, vector large_wave, vector small_wave106vector large_wave, vector small_wave

Vector for the directions of the waves Y represents north/south and X represents movement east/west.

  • large_wave: Large wave speed and direction.

    range = [<-20, -20>, <20, 20>]

  • small_wave: Small wave speed and direction.

    range = [<-20, -20>, <20, 20>]

SKY_AMBIENT0vector colorAmbient color used in the scene.
SKY_BLUE, vector blue_density, vector blue_horizon22vector blue_density, vector blue_horizonChange the colors used to calculate blue density and blue horizon in the environment.
SKY_HAZE, float density, float horizon, float density_multiplier, float distance_multiplier23float density, float horizon, float density_multiplier, float distance_multiplierValues used to calculate the impact of blue_density and blue_horizon on the scene lighting.
SKY_REFLECTION_PROBE_AMBIANCE24float ambianceMinimum ambiance value for all reflection probes. range = [0.0, 10.0] Caveat: This feature will be supported in the upcoming GLTF Materials project. Currently it will only work in supported testing areas with a supported test viewer.
  • The list of valid parameters differs from those available for llGetEnvironment.
  • The agent’s viewer may choose to ignore this command.
  • An environment set locally on the viewer will override any environment set from this function.
  • The ENV_OK constant is only present on Lua-enabled sims. On older sims, use it’s value of 1 instead
Example 1
22 collapsed lines
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)
{
13 collapsed lines
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);
}
}
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.