Skip to content

llReplaceAgentEnvironment

Requires Experience
integer llReplaceAgentEnvironment(key agent_id, float transition, string environment)

Replaces the entire environment for an agent. Must be used as part of an experience.

Parameters
agent_id (key)
transition (float)
environment (string)
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);
}
}
  • 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.
  • If a UUID is passed as the environment parameter and that UUID does not specify an environment setting, the viewer quietly ignores the instruction.
  • The 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.
  • The agent must be in the region and must be participating in the experience.
  • This function must be executed as part of an experience with a valid experience key.