Skip to content
lsl.devlsl.devLSL Dev

llGetEnvironment

function
Function syntax
list llGetEnvironment(
  1. vector pos,// Position vector in region coordinates (X/Y determine the parcel, or region if X/Y are -1; Z determines the sky track altitude).
  2. list params// A list of environmental attributes to retrieve.
);
Returns
list
Energy
10

If an unknown rule is encountered in the parameter list an error is sent to the debug channel.

Returns a list containing the current environment values for the parcel or region as a list of attributes. Takes a list of attributes to retrieve in params and returns them in the order requested.

How to use
list result = llGetEnvironment(ZERO_VECTOR, []);
From the LSL definitions: EnvironmentParamReadOnly (rule and request, then what it returns)
// Sun, moon and starsSKY_SUN → rotation rot, float scale, vector sun_color, integer is_default_texture, vector direction, vector ambient_color, vector diffuse_colorSKY_MOON → rotation rot, float scale, float brightness, integer is_default_texture, vector direction, vector ambient_color, vector diffuse_colorSKY_SUN_TEXTURESKY_MOON_TEXTURESKY_GLOW → float glow_size, float glow_focusSKY_STAR_BRIGHTNESS → float brightness  // 0 to 500SKY_LIGHT → vector light_direction, vector fade_color, vector total_ambient// Sky colour and atmosphereSKY_AMBIENT → vector ambient_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 detail, integer is_defaultSKY_CLOUD_TEXTURE// WaterWATER_FOG → vector color, float density, float modulationWATER_NORMAL_TEXTUREWATER_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// Day cycle and defaultsENVIRONMENT_DAYINFO → integer day_length, integer day_offset, float secs_since_midnightSKY_TRACKS → float sky2, float sky3, float sky4SKY_TEXTURE_DEFAULTS → integer bloom_is_default, integer halo_is_default, integer rainbow_is_defaultWATER_TEXTURE_DEFAULTS → integer normal_is_default, integer transparent_is_default
parameterinteger valuereturn valuesdescription
SKY_TRACKS, float sky2, float sky3, float sky415float sky2, float sky3, float sky4Altitudes for sky transitions in the region.
SKY_AMBIENT0vector ambient_colorThe ambient color of the environment.
SKY_TEXTURE_DEFAULTS, integer bloom_is_default, integer halo_is_default, integer rainbow_is_default1integer bloom_is_default, integer halo_is_default, integer rainbow_is_defaultChecks if the textures are currently set to use the default. For default values, the returned integer is 1. If the texture uses something other than the default, the returned value is 0.
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, integer is_default

Environmental cloud information.

  • color: The color used for the clouds.
  • coverage: The coverage percentage.
  • scale: The scaling applied to the cloud textures.
  • variance: A randomizing factor applied to the main cloud layer
  • scroll: The scroll speed of the clouds.
  • X is east/west
  • Y is north/south
  • Z is unused
  • density: The X/Y and D parameter used to generate cloud density
  • detail: The X/Y and D parameter used to generate cloud details.
  • is_default: 1 if the clouds are using the default texture.
SKY_DOME, float offset, float radius, float max_altitude4float offset, float radius, float max_altitude

Sky dome information.

  • offset
  • radius
  • maximum altitude
SKY_GAMMA5float gammaThe gamma value applied to the scene. In viewer versions 7.0+, this value has been repurposed into the “HDR Scale” value in the EEP editor. (Thus, this will return the value of the HDR Scale slider).
SKY_GLOW, float glow_size, float glow_focus6float glow_size, float glow_focus

Glow applied to the sun and moon.

  • size of glow effect
  • focus of glow effect
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, integer is_default_texture, vector direction, vector ambient_color, vector diffuse_color

Detailed moon information

  • rot: The current rotation applied to the moon.
  • scale: The current scale applied to the moon’s texture
  • brightness: The moon’s brightness
  • is_default_texture: 1 if the moon texture is set to the default. 0 otherwise
  • direction: A unit vector pointing at the moon.
  • ambient_color: The ambient color of the moon
  • diffuse_color: The diffuse color applied to the moon.
SKY_STAR_BRIGHTNESS13float brightness
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, integer is_default_texture, vector direction, vector ambient_color, vector diffuse_color

Detailed sun information

  • rot: The current rotation applied to the sun.
  • scale: The current scale applied to the sun’s texture
  • sun_color:
  • is_default_texture: 1 if the sun texture is set to the default. 0 otherwise
  • direction: A unit vector pointing at the sun.
  • ambient_color: The ambient color of the sun.
  • diffuse_color: The diffuse color applied to 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
  • sky_bottom_radius
  • sky_top_radius
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
  • droplet_radius
  • ice_level
SKY_LIGHT, vector light_direction, vector fade_color, vector total_ambient8vector light_direction, vector fade_color, vector total_ambient

Miscellaneous lighting values

  • light_direction: A unit vector indicating the direction of the dominant light source.
  • fade_color: A color vector representing the current color of the light emitted from the dominant light source (in sRGB space).
  • total_ambient: A color vector representing the current ambient color in use in the scene (in sRGB space).
SKY_REFLECTION_PROBE_AMBIANCE24float ambianceMinimum ambiance value for all reflection probes. range = [0.0, 10.0] Caveat: This parameter will be supported in the upcoming GLTF Materials project. Currently it will only work in supported testing areas with a supported test viewer.
WATER_BLUR_MULTIPLIER100float multiplierMultiplier applied to blur the scene when under water.
WATER_FOG, vector color, float density, float modulation101vector , float density, float modulation

Fog parameters applied when underwater

  • color: The color of the underwater fog
  • density: Density exponent applied to the fog
  • modulation:
WATER_FRESNEL, float offset, float scale102float offset, float scale

Fresnel scattering applied to the surface of the water.

  • offset
  • scale
WATER_TEXTURE_DEFAULTS, integer normal_is_default, integer transparent_is_default103integer normal_is_default, integer transparent_is_defaultChecks if the textures are currently set to use the default. For default values the returned integer is 1, if the texture uses something other than the default this value is 0.
WATER_NORMAL_SCALE104vector scaleScaling applied to the water normal map.
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
  • scale_below
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.
  • small_wave: Small wave speed and direction.
ENVIRONMENT_DAYINFO, integer day_length, integer day_offset, float secs_since_midnight200integer day_length, integer day_offset, float secs_since_midnight

Current time and day information

  • day_length: Number of seconds in the environments day cycle.
  • day_offset: Number of seconds day cycle is offset from GMT.
  • secs_since_midnight: Number of seconds elapsed since the last day cycle midnight.
  • If the script can not run in the requested parcel, this function returns an empty list and issues a warning in the debug channel.
  • SKY_LIGHT’s param fade_color does not return a clamped value, meaning an unusually bright scene will cause it to return an out-of-bounds color. (This can be fixed by clamping the value manually, but this should really return a clamped value).
Example 1
default
{
touch_start(integer total_number)
{
list environment = llGetEnvironment(llGetPos(), [SKY_TRACKS, SKY_AMBIENT, SKY_CLOUDS]);
llOwnerSay(llDumpList2String(environment, ", "));
}
}
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.