OsSetSitActiveRange
From OpenSimulator
(Difference between revisions)
(2 intermediate revisions by 2 users 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 | ||
|delay=0 | |delay=0 | ||
− | |ossl_example= | + | |ossl_example=<source lang="lsl"> |
+ | // 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 | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
|additional_info=This function was added in 0.9.2.0 | |additional_info=This function was added in 0.9.2.0 | ||
}} | }} |
Latest revision as of 23:04, 5 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 |