OsReplaceAgentEnvironment
From OpenSimulator
(Difference between revisions)
m (Add Author) |
m (Small changes in the script) |
||
(10 intermediate revisions by one user not shown) | |||
Line 9: | Line 9: | ||
* if return value is negative, it failed. | * if return value is negative, it failed. | ||
* 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. | ||
+ | ''' The errors returned are: ''' | ||
+ | return 0 : Never 0 for now | ||
+ | return 1 : if daycycle applied with success | ||
+ | return -1 : Never -1 | ||
+ | return -2 : if no ossl rights | ||
+ | return -3 : if daycycle asset not found | ||
+ | return -4 : if agent not found | ||
+ | return -5 : if fail to decode daycycle asset | ||
|ossl_example=<source lang="lsl"> | |ossl_example=<source lang="lsl"> | ||
− | |||
// | // | ||
// osReplaceAgentEnvironment Script Example | // osReplaceAgentEnvironment Script Example | ||
// Author: djphil | // Author: djphil | ||
// | // | ||
− | + | ||
// 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 | + | string daycycle_a = "Daycycle_A"; |
− | string | + | string daycycle_b = NULL_KEY; |
integer transition = 3; | integer transition = 3; | ||
integer switch; | integer switch; | ||
Line 27: | Line 34: | ||
{ | { | ||
llSay(PUBLIC_CHANNEL, "Touch to see osReplaceAgentEnvironment usage."); | llSay(PUBLIC_CHANNEL, "Touch to see osReplaceAgentEnvironment usage."); | ||
+ | llSay(PUBLIC_CHANNEL, "Transition: " + (string)transition + " second(s)."); | ||
} | } | ||
− | + | ||
touch_start(integer number) | touch_start(integer number) | ||
{ | { | ||
key agentKey = llDetectedKey(0); | key agentKey = llDetectedKey(0); | ||
− | + | ||
if (llGetAgentSize(agentKey) != ZERO_VECTOR) | if (llGetAgentSize(agentKey) != ZERO_VECTOR) | ||
{ | { | ||
integer result; | integer result; | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
if (switch = !switch) | if (switch = !switch) | ||
{ | { | ||
− | result = osReplaceAgentEnvironment(agentKey, transition, | + | result = osReplaceAgentEnvironment(agentKey, transition, daycycle_a); |
− | llRegionSayTo(agentKey, PUBLIC_CHANNEL, " | + | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_a: " + daycycle_a); |
} | } | ||
− | + | ||
else | else | ||
{ | { | ||
− | result = osReplaceAgentEnvironment(agentKey, transition, | + | result = osReplaceAgentEnvironment(agentKey, transition, daycycle_b); |
− | llRegionSayTo(agentKey, PUBLIC_CHANNEL, " | + | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_b: " + daycycle_b); |
} | } | ||
− | + | ||
− | if ( | + | if (daycycle_a == "" || daycycle_a == NULL_KEY || daycycle_b == "" || daycycle_b == NULL_KEY) |
+ | { | ||
+ | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "The normal environment for the parcel or region has been selected."); | ||
+ | } | ||
+ | |||
+ | if (result > 0) | ||
{ | { | ||
llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced with success!"); | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced with success!"); | ||
} | } | ||
− | + | ||
− | else | + | else if (result < 0) |
{ | { | ||
llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced without success!"); | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced without success!"); | ||
} | } | ||
+ | } | ||
+ | |||
+ | else | ||
+ | { | ||
+ | llInstantMessage(agentKey, "You need to be in the same region to use this function ..."); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | '''With all errors message:''' | ||
+ | <source lang="lsl"> | ||
+ | // | ||
+ | // osReplaceAgentEnvironment Script Example | ||
+ | // Author: djphil | ||
+ | // | ||
+ | |||
+ | // Can be asset's name in object's inventory or the asset uuid | ||
+ | string daycycle_a = "Daycycle_A"; | ||
+ | string daycycle_b = NULL_KEY; | ||
+ | integer transition = 3; | ||
+ | integer switch; | ||
+ | |||
+ | default | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | llSay(PUBLIC_CHANNEL, "Touch to see osReplaceAgentEnvironment usage."); | ||
+ | llSay(PUBLIC_CHANNEL, "Transition: " + (string)transition + " second(s)."); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | key agentKey = llDetectedKey(0); | ||
+ | |||
+ | integer result; | ||
+ | |||
+ | if (switch = !switch) | ||
+ | { | ||
+ | result = osReplaceAgentEnvironment(agentKey, transition, daycycle_a); | ||
+ | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_a: " + daycycle_a); | ||
} | } | ||
else | else | ||
{ | { | ||
− | llRegionSayTo(agentKey, PUBLIC_CHANNEL, " | + | result = osReplaceAgentEnvironment(agentKey, transition, daycycle_b); |
+ | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_b: " + daycycle_b); | ||
+ | } | ||
+ | |||
+ | if (daycycle_a == "" || daycycle_a == NULL_KEY || daycycle_b == "" || daycycle_b == NULL_KEY) | ||
+ | { | ||
+ | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "The normal environment for the parcel or region has been selected."); | ||
+ | } | ||
+ | |||
+ | if (result > 0) | ||
+ | { | ||
+ | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced with success!"); | ||
+ | } | ||
+ | |||
+ | else if (result < 0) | ||
+ | { | ||
+ | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced without success!"); | ||
+ | |||
+ | if (result == -2) | ||
+ | { | ||
+ | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "You don't have OSSL rights ..."); | ||
+ | } | ||
+ | |||
+ | if (result == -3) | ||
+ | { | ||
+ | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "The daycycle asset is not found ..."); | ||
+ | } | ||
+ | |||
+ | if (result == -4) | ||
+ | { | ||
+ | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "The agent is not found ..."); | ||
+ | } | ||
+ | |||
+ | if (result == -5) | ||
+ | { | ||
+ | llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Fail to decode daycycle asset ..."); | ||
+ | } | ||
} | } | ||
} | } | ||
Line 72: | Line 158: | ||
|additional_info=This function was added in 0.9.2 | |additional_info=This function was added in 0.9.2 | ||
}} | }} | ||
+ | == See Also == | ||
+ | * [[osReplaceAgentEnvironment]] | ||
+ | * [[osReplaceParcelEnvironment]] | ||
+ | * [[osReplaceRegionEnvironment]] | ||
+ | * [[osResetEnvironment]] |
Latest revision as of 12:07, 21 December 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
The errors returned are: return 0 : Never 0 for now return 1 : if daycycle applied with success return -1 : Never -1 return -2 : if no ossl rights return -3 : if daycycle asset not found return -4 : if agent not found return -5 : if fail to decode daycycle asset | |
Threat Level | Moderate |
Permissions | ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER |
Extra Delay | 0 seconds |
Example(s) | |
// // osReplaceAgentEnvironment Script Example // Author: djphil // // Can be asset's name in object's inventory or the asset uuid string daycycle_a = "Daycycle_A"; string daycycle_b = NULL_KEY; integer transition = 3; integer switch; default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see osReplaceAgentEnvironment usage."); llSay(PUBLIC_CHANNEL, "Transition: " + (string)transition + " second(s)."); } touch_start(integer number) { key agentKey = llDetectedKey(0); if (llGetAgentSize(agentKey) != ZERO_VECTOR) { integer result; if (switch = !switch) { result = osReplaceAgentEnvironment(agentKey, transition, daycycle_a); llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_a: " + daycycle_a); } else { result = osReplaceAgentEnvironment(agentKey, transition, daycycle_b); llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_b: " + daycycle_b); } if (daycycle_a == "" || daycycle_a == NULL_KEY || daycycle_b == "" || daycycle_b == NULL_KEY) { llRegionSayTo(agentKey, PUBLIC_CHANNEL, "The normal environment for the parcel or region has been selected."); } if (result > 0) { llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced with success!"); } else if (result < 0) { llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced without success!"); } } else { llInstantMessage(agentKey, "You need to be in the same region to use this function ..."); } } } With all errors message: // // osReplaceAgentEnvironment Script Example // Author: djphil // // Can be asset's name in object's inventory or the asset uuid string daycycle_a = "Daycycle_A"; string daycycle_b = NULL_KEY; integer transition = 3; integer switch; default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see osReplaceAgentEnvironment usage."); llSay(PUBLIC_CHANNEL, "Transition: " + (string)transition + " second(s)."); } touch_start(integer number) { key agentKey = llDetectedKey(0); integer result; if (switch = !switch) { result = osReplaceAgentEnvironment(agentKey, transition, daycycle_a); llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_a: " + daycycle_a); } else { result = osReplaceAgentEnvironment(agentKey, transition, daycycle_b); llRegionSayTo(agentKey, PUBLIC_CHANNEL, "daycycle_b: " + daycycle_b); } if (daycycle_a == "" || daycycle_a == NULL_KEY || daycycle_b == "" || daycycle_b == NULL_KEY) { llRegionSayTo(agentKey, PUBLIC_CHANNEL, "The normal environment for the parcel or region has been selected."); } if (result > 0) { llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced with success!"); } else if (result < 0) { llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Agent environment replaced without success!"); if (result == -2) { llRegionSayTo(agentKey, PUBLIC_CHANNEL, "You don't have OSSL rights ..."); } if (result == -3) { llRegionSayTo(agentKey, PUBLIC_CHANNEL, "The daycycle asset is not found ..."); } if (result == -4) { llRegionSayTo(agentKey, PUBLIC_CHANNEL, "The agent is not found ..."); } if (result == -5) { llRegionSayTo(agentKey, PUBLIC_CHANNEL, "Fail to decode daycycle asset ..."); } } } } | |
Notes | |
This function was added in 0.9.2 |
[edit] See Also
- osReplaceAgentEnvironment
- osReplaceParcelEnvironment
- osReplaceRegionEnvironment
- osResetEnvironment