OsSetLinkSitActiveRange
From OpenSimulator
(Difference between revisions)
(Add exemple script) |
|||
Line 14: | Line 14: | ||
// Example of osSetLinkSitActiveRange | // Example of osSetLinkSitActiveRange | ||
− | vector target = <0.0, 0.3, 0.55>; | + | vector target = <0.0, 0.3, 0.55>; // Target position where avatars will sit |
− | vector rotate = <0.0, 0.0, 90.0>; | + | vector rotate = <0.0, 0.0, 90.0>; // Rotation of the sitting avatar |
− | float active_link_range = 5.0; | + | float active_link_range = 5.0; // Initial active link range |
− | integer link = 2; | + | integer link = 2; // Link number of the prim |
− | key avatar; | + | key avatar; // Key of the avatar currently sitting |
+ | // Function to debug and display active link range for an avatar | ||
debug(string name) | debug(string name) | ||
{ | { | ||
Line 30: | Line 31: | ||
state_entry() | state_entry() | ||
{ | { | ||
+ | // Stand up any avatars currently sitting on the prim | ||
llUnSit(llAvatarOnSitTarget()); | llUnSit(llAvatarOnSitTarget()); | ||
+ | |||
+ | // Set click action to allow sitting on the prim | ||
llSetClickAction(CLICK_ACTION_SIT); | llSetClickAction(CLICK_ACTION_SIT); | ||
+ | |||
+ | // Set the sit target and rotation for the linked prim | ||
llLinkSitTarget(link, target, llEuler2Rot((rotate * DEG_TO_RAD))); | llLinkSitTarget(link, target, llEuler2Rot((rotate * DEG_TO_RAD))); | ||
+ | |||
+ | // Set the initial active sit range for the linked prim | ||
osSetLinkSitActiveRange(link, active_link_range); | osSetLinkSitActiveRange(link, active_link_range); | ||
} | } | ||
− | + | ||
changed(integer change) | changed(integer change) | ||
{ | { | ||
+ | // Check if a link has been changed | ||
if (change & CHANGED_LINK) | if (change & CHANGED_LINK) | ||
{ | { | ||
+ | // Get the key of the avatar sitting on the prim | ||
key user = llAvatarOnSitTarget(); | key user = llAvatarOnSitTarget(); | ||
− | + | ||
+ | // If an avatar is sitting on the prim | ||
if (user != NULL_KEY) | if (user != NULL_KEY) | ||
{ | { | ||
avatar = user; | avatar = user; | ||
− | debug(osKey2Name(avatar)); | + | debug(osKey2Name(avatar)); // Debug and display active link range |
} | } | ||
− | + | // If no avatar is sitting on the prim | |
else if (user == NULL_KEY) | else if (user == NULL_KEY) | ||
{ | { | ||
− | debug(osKey2Name(avatar)); | + | debug(osKey2Name(avatar)); // Debug and display active link range |
avatar = NULL_KEY; | avatar = NULL_KEY; | ||
} | } | ||
− | + | // Reset the script if an unexpected condition occurs | |
else | else | ||
{ | { |
Latest revision as of 22:53, 5 March 2024
osSetLinkSitActiveRange(integer linkNumber, float range)
| |
sets a limit on how far a avatar can be to have a sit request accepted, or disable sits
this value is stored on 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 osSetLinkSitActiveRange vector target = <0.0, 0.3, 0.55>; // Target position where avatars will sit vector rotate = <0.0, 0.0, 90.0>; // Rotation of the sitting avatar float active_link_range = 5.0; // Initial active link range integer link = 2; // Link number of the prim key avatar; // Key of the avatar currently sitting // Function to debug and display active link range for an avatar debug(string name) { active_link_range = osGetLinkSitActiveRange(link); llOwnerSay("active_link_range for avatar " + name + " is " + (string)active_link_range); } default { state_entry() { // Stand up any avatars currently sitting on the prim llUnSit(llAvatarOnSitTarget()); // Set click action to allow sitting on the prim llSetClickAction(CLICK_ACTION_SIT); // Set the sit target and rotation for the linked prim llLinkSitTarget(link, target, llEuler2Rot((rotate * DEG_TO_RAD))); // Set the initial active sit range for the linked prim osSetLinkSitActiveRange(link, active_link_range); } changed(integer change) { // Check if a link has been changed if (change & CHANGED_LINK) { // Get the key of the avatar sitting on the prim key user = llAvatarOnSitTarget(); // If an avatar is sitting on the prim if (user != NULL_KEY) { avatar = user; debug(osKey2Name(avatar)); // Debug and display active link range } // If no avatar is sitting on the prim else if (user == NULL_KEY) { debug(osKey2Name(avatar)); // Debug and display active link range avatar = NULL_KEY; } // Reset the script if an unexpected condition occurs else { llResetScript(); } } } } | |
Notes | |
This function was added in 0.9.2.0 |