OsReplaceAgentEnvironment

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Add a second exemple)
(Made all in one script's)
Line 10: Line 10:
 
* transition should be the viewer transition time to the new one. May not work on most viewers.
 
* transition should be the viewer transition time to the new one. May not work on most viewers.
 
|ossl_example=<source lang="lsl">
 
|ossl_example=<source lang="lsl">
 +
//
 
//
 
//
 
// osReplaceAgentEnvironment Script Example
 
// osReplaceAgentEnvironment Script Example
Line 15: Line 16:
  
 
// Can be asset's name in object's inventory or the asset uuid
 
// Can be asset's name in object's inventory or the asset uuid
string daycycle_a = "A-12AM";
+
string daycycle_1 = "A-12AM";
string daycycle_b = NULL_KEY;
+
string daycycle_2 = NULL_KEY;
 
integer transition = 3;
 
integer transition = 3;
 
integer switch;
 
integer switch;
Line 30: Line 31:
 
     {
 
     {
 
         key agentKey = llDetectedKey(0);
 
         key agentKey = llDetectedKey(0);
 
        llSay(PUBLIC_CHANNEL, "agentKey: " + (string)agentKey);
 
        llSay(PUBLIC_CHANNEL, "transition: " + (string)transition);
 
 
        if (switch =! switch)
 
        {
 
            osReplaceAgentEnvironment(agentKey, transition, daycycle_a);
 
            llSay(PUBLIC_CHANNEL, "daycycle_a: " + daycycle_a);
 
        }
 
 
          
 
          
        else
 
        {
 
            osReplaceAgentEnvironment(agentKey, transition, daycycle_b);
 
            llSay(PUBLIC_CHANNEL, "daycycle_b: " + daycycle_b);
 
        }
 
    }
 
}
 
</source>
 
<source lang="lsl">
 
//
 
// osReplaceAgentEnvironment Script Example
 
//
 
 
// Can be asset's name in object's inventory or the asset uuid
 
string daycycle = "A-12AM";
 
integer transition = 3;
 
 
default
 
{
 
    state_entry()
 
    {
 
        llSay(PUBLIC_CHANNEL, "Touch to see osReplaceAgentEnvironment usage.");
 
    }
 
 
    touch_start(integer number)
 
    {
 
        key agentKey = llDetectedKey(0);
 
 
 
         if (llGetAgentSize(agentKey) != ZERO_VECTOR)
 
         if (llGetAgentSize(agentKey) != ZERO_VECTOR)
 
         {
 
         {
             integer result = osReplaceAgentEnvironment(agentKey, transition, daycycle);
+
             integer result;
  
 +
            llRegionSayTo(agentKey, PUBLIC_CHANNEL, "agentKey: " + (string)agentKey);
 +
            llRegionSayTo(agentKey, PUBLIC_CHANNEL, "transition: " + (string)transition);
 +
   
 +
            if (switch = !switch)
 +
            {
 +
                result = osReplaceAgentEnvironment(agentKey, transition, daycycle_1);
 +
                llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_1: " + daycycle_1);
 +
            }
 +
           
 +
            else
 +
            {
 +
                result = osReplaceAgentEnvironment(agentKey, transition, daycycle_2);
 +
                llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_2: " + daycycle_2);
 +
            }
 +
           
 
             if (result == 1)
 
             if (result == 1)
 
             {
 
             {
                 llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Applying environment for " + osKey2Name(agentKey));
+
                 llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced with success!");
 
             }
 
             }
 
+
           
 
             else
 
             else
 
             {
 
             {
                 llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Cannot apply environment for " + osKey2Name(agentKey) + " due to reason id : " + (string)result);
+
                 llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced without success!");
 
             }
 
             }
 
         }
 
         }

Revision as of 02:41, 28 November 2020

integer osReplaceAgentEnvironment(key agentKey, integer transition, string daycycle)
Forces a dayclycle on a agent. Will do nothing if the agent is using a viewer local environment
  • If parameter daycycle is NULL_KEY or "", agent will see normal environment for parcel or region,
  • daycycle can be a name of a daycycle asset on prim contents. If it is a UUID it can also be grid asset.
  • if return value is negative, it failed.
  • transition should be the viewer transition time to the new one. May not work on most viewers.
Threat Level Moderate
Permissions ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
Extra Delay 0 seconds
Example(s)
//
//
// osReplaceAgentEnvironment Script Example
//
 
// Can be asset's name in object's inventory or the asset uuid
string daycycle_1 = "A-12AM";
string daycycle_2 = NULL_KEY;
integer transition = 3;
integer switch;
 
default
{
    state_entry()
    {
        llSay(PUBLIC_CHANNEL, "Touch to see osReplaceAgentEnvironment usage.");
    }
 
    touch_start(integer number)
    {
        key agentKey = llDetectedKey(0);
 
        if (llGetAgentSize(agentKey) != ZERO_VECTOR)
        {
            integer result;
 
            llRegionSayTo(agentKey, PUBLIC_CHANNEL, "agentKey: " + (string)agentKey);
            llRegionSayTo(agentKey, PUBLIC_CHANNEL, "transition: " + (string)transition);
 
            if (switch = !switch)
            {
                result = osReplaceAgentEnvironment(agentKey, transition, daycycle_1);
                llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_1: " + daycycle_1);
            }
 
            else
            {
                result = osReplaceAgentEnvironment(agentKey, transition, daycycle_2);
                llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_2: " + daycycle_2);
            }
 
            if (result == 1)
            {
                llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced with success!");
            }
 
            else
            {
                llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced without success!");
            }
        }
 
        else
        {
            llRegionSayTo(agentKey, PUBLIC_CHANNEL, "You need to be in the same region to change environment.");
        }
    }
}
Notes
This function was added in 0.9.2
Personal tools
General
About This Wiki