Difference between revisions of "LlReplaceEnvironment"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "{{LSL_Function |func=llReplaceEnvironment |func_desc=The llReplaceEnvironment function replaces the environment in a parcel or a region. Either for a single elevation track or...")
 
(Clarify that modifying a group parcel requires the script to be group-owned or for the owner to have the appropriate ability and be present in the sim.)
 
(6 intermediate revisions by 4 users not shown)
Line 6: Line 6:
|p1_type=vector|p1_name=position|p1_desc=The position in the region of the parcel that will receive the new environment. To change the entire region use <-1, -1, -1>. The z component of the vector is ignored.
|p1_type=vector|p1_name=position|p1_desc=The position in the region of the parcel that will receive the new environment. To change the entire region use <-1, -1, -1>. The z component of the vector is ignored.
|p2_type=string|p2_name=environment|p2_desc=The name of an environmental setting in the object's inventory or the asset ID for an environment. NULL_KEY or empty string to remove the environment.
|p2_type=string|p2_name=environment|p2_desc=The name of an environmental setting in the object's inventory or the asset ID for an environment. NULL_KEY or empty string to remove the environment.
|p3_type=integer|p3_name=track_no|p3_desc=The elevation zone to change. 0 for water, 1 for ground level. -1 to change all tracks.
|p3_type=integer|p3_name=track_no|p3_desc=The elevation zone to change. 0 for water, 1 for ground level, 2 for sky 1000m, 3 for sky 2000m, 4 for sky 3000m. -1 to change all tracks.
|p4_type=integer|p4_name=day_length|p4_desc=The length in seconds for the day cycle. -1 to leave unchanged.
|p4_type=integer|p4_name=day_length|p4_desc=The length in seconds for the day cycle. -1 to leave unchanged.
|p5_type=integer|p5_name=day_offset|p5_desc=The offset in seconds from GMT. -1 to leave unchanged.
|p5_type=integer|p5_name=day_offset|p5_desc=The offset in seconds from UTC. -1 to leave unchanged.
|constants=
|constants=
{{{!}} class="sortable" {{Prettytable|style=margin-top:0;}}
{{{!}} class="sortable" {{Prettytable|style=margin-top:0;}}
Line 27: Line 27:
|caveats=
|caveats=
* An environment set locally on the viewer will override any environment set from this function.
* An environment set locally on the viewer will override any environment set from this function.
* If a UUID is passed as the environment parameter and that UUID does not specify an environment setting or one can not be constructed, the function will return success (1) but will post a message to the debug channel.  
* A parameter override set by [[llSetEnvironment]] will be preserved after the environment is replaced by this function.  Call [[llSetEnvironment]] with an empty list parameter to clear any straggling overrides.
|examples=
* The environment specified by this function is applied asynchronously, as the simulator must download the environment asset before applying it. This means that [[llGetEnvironment]] will not immediately reflect the new environment's parameters, although the delay is typically quite small.
* If a UUID is passed as the environment parameter and that UUID does not specify an environment setting or one can not be constructed, the function will return success (1) but will post a message to the debug channel.
* If the parcel is group-owned, the script must either be deeded to the group, or the script owner must have "Modify environment settings and day cycle" group ability '''and''' have an active agent in the sim.
|examples=<source lang="lsl2">
//  Will set the entire region to the "Tropicalia" EEP from the Linden inventory when touched.
//  It will set all the tracks to the same EEP with 24 hour day and a -8 hour Day Offset.
//  The "Tropicalia" must be in the prims inventory with the script. 
//
//  Limited to Estate Managers or Region owners.
//  Madi Perth - 4/17/2023
 
default
{
 
    touch_start(integer total_number)
    {
        llReplaceEnvironment(<-1, -1, -1>, "Tropicalia", -1, 86400, (86400-28800));
    }
}
</source>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llSetAgentEnvironment]]|}}
|also_functions={{LSL DefineRow||[[llSetAgentEnvironment]]|}}
Line 34: Line 53:
{{LSL DefineRow||[[llSetEnvironment]]|}}
{{LSL DefineRow||[[llSetEnvironment]]|}}
|notes
|notes
|history = Date of Release  [https://releasenotes.secondlife.com/simulator/2022-08-12.574216.html 12/08/2022]
}}
}}

Latest revision as of 10:41, 27 March 2024

Summary

Function: Integer llReplaceEnvironment( vector position, string environment, integer track_no, integer day_length, integer day_offset );

The llReplaceEnvironment function replaces the environment in a parcel or a region. Either for a single elevation track or the entire environment. The owner of the script must have permission to edit the environment on the destination parcel, or be an estate manage in the case of an entire region. In most cases errors are reported as a return value from the function (see table below). However, issues with the environment assets may be reported in the debug chat.
Returns an Integer

• vector position The position in the region of the parcel that will receive the new environment. To change the entire region use <-1, -1, -1>. The z component of the vector is ignored.
• string environment The name of an environmental setting in the object's inventory or the asset ID for an environment. NULL_KEY or empty string to remove the environment.
• integer track_no The elevation zone to change. 0 for water, 1 for ground level, 2 for sky 1000m, 3 for sky 2000m, 4 for sky 3000m. -1 to change all tracks.
• integer day_length The length in seconds for the day cycle. -1 to leave unchanged.
• integer day_offset The offset in seconds from UTC. -1 to leave unchanged.

Return Values
Value Constant Description
1 The parcel or region will attempt to change the applied environment.
ENV_NO_ENVIRONMENT -3 The environment inventory object could not be found.
ENV_THROTTLE -8 The scripts have exceeded the throttle. Wait and retry the request.
ENV_NO_PERMISSIONS -9 The script does not have permission to change the environment at the selected location.
OR
there was an attempt to remove altitude track 0 or 1 (in this case a message will also be chatted to the debug channel).

Caveats

  • An environment set locally on the viewer will override any environment set from this function.
  • A parameter override set by llSetEnvironment will be preserved after the environment is replaced by this function. Call llSetEnvironment with an empty list parameter to clear any straggling overrides.
  • The environment specified by this function is applied asynchronously, as the simulator must download the environment asset before applying it. This means that llGetEnvironment will not immediately reflect the new environment's parameters, although the delay is typically quite small.
  • If a UUID is passed as the environment parameter and that UUID does not specify an environment setting or one can not be constructed, the function will return success (1) but will post a message to the debug channel.
  • If the parcel is group-owned, the script must either be deeded to the group, or the script owner must have "Modify environment settings and day cycle" group ability and have an active agent in the sim.

Examples

//  Will set the entire region to the "Tropicalia" EEP from the Linden inventory when touched. 
//  It will set all the tracks to the same EEP with 24 hour day and a -8 hour Day Offset.
//  The "Tropicalia" must be in the prims inventory with the script.  
//
//  Limited to Estate Managers or Region owners.
//  Madi Perth - 4/17/2023

default
{

    touch_start(integer total_number)
    {
        llReplaceEnvironment(<-1, -1, -1>, "Tropicalia", -1, 86400, (86400-28800));
    }
}

See Also

Deep Notes

History

Date of Release 12/08/2022

Signature

function Integer llReplaceEnvironment( vector position, string environment, integer track_no, integer day_length, integer day_offset );