OsSetSitActiveRange: Difference between revisions
From OpenSimulator
Jump to navigationJump to search
imported>Djphil Add exemple script |
No edit summary |
||
| (One intermediate revision by one other user not shown) | |||
| Line 2: | Line 2: | ||
|function_syntax=osSetSitActiveRange(float range) | |function_syntax=osSetSitActiveRange(float range) | ||
|csharp_syntax= | |csharp_syntax= | ||
|description= sets a limit on how far a avatar can be to have a sit request accepted, or disable sits | |description= sets a limit on how far a avatar can be to have a sit request accepted, or disable sits. | ||
* range > 0: if a avatar | * range > 0: sit request is silently ignored if a avatar is further than range from the prim. | ||
* range == 0: disables this limit. Region default is used. | * range == 0: disables this limit. Region default is used. Currently range is unlimited if a sit target is set or physics can sit the avatar, otherwise 10m. | ||
* range < 0: sits are disabled. Requests are silently ignored | * range < 0: sits are disabled. Requests are silently ignored. | ||
The range value is stored in the prim, even if the script is removed | |||
|threat_level= None | |threat_level= None | ||
|permissions= true | |permissions= true | ||
| Line 13: | Line 13: | ||
// Example of osSetSitActiveRange | // Example of osSetSitActiveRange | ||
vector target = <0.0, 0.3, 0.55>; | vector target = <0.0, 0.3, 0.55>; // Defines the position where avatars will sit | ||
vector rotate = <0.0, 0.0, 90.0>; | vector rotate = <0.0, 0.0, 90.0>; // Defines the rotation of the seated avatars | ||
float active_range = 5.0; | float active_range = 5.0; // Specifies the range within which avatars are considered active | ||
key avatar; | key avatar; // Stores the key of the currently seated avatar | ||
// Function to output debug messages | |||
debug(string name) | debug(string name) | ||
{ | { | ||
active_range = osGetSitActiveRange(); | active_range = osGetSitActiveRange(); // Updates the active range | ||
llOwnerSay("active_range for avatar " + name + " is " + (string)active_range); | llOwnerSay("active_range for avatar " + name + " is " + (string)active_range); // Outputs debug message | ||
} | } | ||
| Line 28: | Line 29: | ||
state_entry() | state_entry() | ||
{ | { | ||
llUnSit(llAvatarOnSitTarget()); | llUnSit(llAvatarOnSitTarget()); // Ensures no avatar is currently seated | ||
llSetClickAction(CLICK_ACTION_SIT); | llSetClickAction(CLICK_ACTION_SIT); // Sets click action to trigger sitting behavior | ||
llSitTarget(target, llEuler2Rot((rotate * DEG_TO_RAD))); | llSitTarget(target, llEuler2Rot((rotate * DEG_TO_RAD))); // Sets the sitting target position and rotation | ||
osSetSitActiveRange(active_range); | osSetSitActiveRange(active_range); // Sets the active range for avatar sitting | ||
} | } | ||
changed(integer change) | changed(integer change) | ||
{ | { | ||
if (change & CHANGED_LINK) | if (change & CHANGED_LINK) // Checks if there's a change in links (i.e., avatar sitting) | ||
{ | { | ||
key user = llAvatarOnSitTarget(); | key user = llAvatarOnSitTarget(); // Gets the key of the avatar sitting on the target | ||
if (user != NULL_KEY) | if (user != NULL_KEY) // If an avatar is sitting on the target | ||
{ | { | ||
avatar = user; | avatar = user; // Stores the key of the seated avatar | ||
debug(osKey2Name(avatar)); | debug(osKey2Name(avatar)); // Outputs debug message with the name of the seated avatar | ||
} | } | ||
else if (user == NULL_KEY) // If no avatar is sitting on the target | |||
else if (user == NULL_KEY) | |||
{ | { | ||
debug(osKey2Name(avatar)); | debug(osKey2Name(avatar)); // Outputs debug message with the name of the previously seated avatar | ||
avatar = NULL_KEY; | avatar = NULL_KEY; // Resets the stored avatar key | ||
} | } | ||
else // If an unexpected situation occurs | |||
else | |||
{ | { | ||
llResetScript(); | llResetScript(); // Resets the script | ||
} | } | ||
} | } | ||
Latest revision as of 18:02, 8 March 2024
osSetSitActiveRange(float range)
| |
sets a limit on how far a avatar can be to have a sit request accepted, or disable sits.
The range value is stored in the prim, even if the script is removed | |
| Threat Level | None |
| Permissions | Use of this function is always allowed by default |
| Extra Delay | 0 seconds |
| Example(s) | |
// Example of osSetSitActiveRange
vector target = <0.0, 0.3, 0.55>; // Defines the position where avatars will sit
vector rotate = <0.0, 0.0, 90.0>; // Defines the rotation of the seated avatars
float active_range = 5.0; // Specifies the range within which avatars are considered active
key avatar; // Stores the key of the currently seated avatar
// Function to output debug messages
debug(string name)
{
active_range = osGetSitActiveRange(); // Updates the active range
llOwnerSay("active_range for avatar " + name + " is " + (string)active_range); // Outputs debug message
}
default
{
state_entry()
{
llUnSit(llAvatarOnSitTarget()); // Ensures no avatar is currently seated
llSetClickAction(CLICK_ACTION_SIT); // Sets click action to trigger sitting behavior
llSitTarget(target, llEuler2Rot((rotate * DEG_TO_RAD))); // Sets the sitting target position and rotation
osSetSitActiveRange(active_range); // Sets the active range for avatar sitting
}
changed(integer change)
{
if (change & CHANGED_LINK) // Checks if there's a change in links (i.e., avatar sitting)
{
key user = llAvatarOnSitTarget(); // Gets the key of the avatar sitting on the target
if (user != NULL_KEY) // If an avatar is sitting on the target
{
avatar = user; // Stores the key of the seated avatar
debug(osKey2Name(avatar)); // Outputs debug message with the name of the seated avatar
}
else if (user == NULL_KEY) // If no avatar is sitting on the target
{
debug(osKey2Name(avatar)); // Outputs debug message with the name of the previously seated avatar
avatar = NULL_KEY; // Resets the stored avatar key
}
else // If an unexpected situation occurs
{
llResetScript(); // Resets the script
}
}
}
}
| |
| Notes | |
| This function was added in 0.9.2.0 | |