Difference between revisions of "LlUnSit"

From Second Life Wiki
Jump to navigation Jump to search
(Undo revision 454153 by Zai Lynch (Talk) whoops)
(Changed examples. More info notes. Using method more useful to note when learning. Included note and example demonstrating that changed is triggered by the un-sitting too.)
Line 10: Line 10:
|constants
|constants
|examples=
|examples=
<lsl>//Unsit on Sit, requires a sit target
<lsl>// UnSit on Sit, Using a sit target
default
default
{
{
     state_entry()
     state_entry()
     {
     {
         llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION); //needed for llAvatarOnSitTarget to work. The vectors components must not all be set to 0.
         llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION); // Needed for llAvatarOnSitTarget to work. The vectors components must not all be set to 0.0
     }
     }
     changed(integer change) //event changed
     changed(integer change) // Triggered when various changes are sensed.
     {
     {
         if (change & CHANGED_LINK) //event changed and it has something to do with linking or avatar sitting
         if(change & CHANGED_LINK) // When an agent sits on an object they become a new link.
         {
         {
             key user = llAvatarOnSitTarget();
             key user = llAvatarOnSitTarget(); // Store the UUID of any agent sitting on the sit target.
             if (user) //the changed event is an avatar sitting
             if(user) // An avatar is on the sit target.
                 llUnSit(user); //unsit the avatar on the sit target
                 llUnSit(user); // Un-Sit the avatar.
         }
         }
     }
     }
}</lsl>
}</lsl>
<lsl>//Unsit on Sit, does not use a sit target
<lsl>// UnSit on Sit, NOT using a sit target
 
default
default
{
{
     changed(integer change) //event changed
     changed(integer change) // Triggered when various changes are sensed.
     {
     {
         if (change & CHANGED_LINK) //event changed and it has something to do with linking or avatar sitting
         if(change & CHANGED_LINK) // When an agent sits on an object they become a new link.
         {
         {
             integer link = llGetNumberOfPrims();
             integer links = 0; // Create an integer type variable.
             key id;
            if(llGetObjectPrimCount(llGetKey()) < (links = llGetNumberOfPrims())) // During the check store the number of links.
             while(llGetAgentSize(id = llGetLinkKey(link--)))
             // If the number of prims is fewer than the number of links, the last must be an avatar.
                llUnSit(id);
             llUnSit(llGetLinkKey(links)); // Use the key of the last link to be added (the avatar) to call llUnSit().
            else
            llOwnerSay("Some kind of linking or unlinking has changed me but, I am not being sat on.");
            // llUnSit() triggers the changed event too (the number of links is reduced by 1).
         }
         }
     }
     }

Revision as of 11:46, 17 May 2010

Summary

Function: llUnSit( key id );

If the agent identified by id is sitting on the object the script is attached to or is over land owned by the object's owner, the agent is forced to stand up.

• key id avatar UUID that is in the same region

Examples

<lsl>// UnSit on Sit, Using a sit target default {

   state_entry()
   {
       llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION); // Needed for llAvatarOnSitTarget to work. The vectors components must not all be set to 0.0
   }
   changed(integer change) // Triggered when various changes are sensed.
   {
       if(change & CHANGED_LINK) // When an agent sits on an object they become a new link.
       {
           key user = llAvatarOnSitTarget(); // Store the UUID of any agent sitting on the sit target.
           if(user) // An avatar is on the sit target.
               llUnSit(user); // Un-Sit the avatar.
       }
   }

}</lsl> <lsl>// UnSit on Sit, NOT using a sit target

default {

   changed(integer change) // Triggered when various changes are sensed.
   {
       if(change & CHANGED_LINK) // When an agent sits on an object they become a new link.
       {
           integer links = 0; // Create an integer type variable.
           if(llGetObjectPrimCount(llGetKey()) < (links = llGetNumberOfPrims())) // During the check store the number of links.
           // If the number of prims is fewer than the number of links, the last must be an avatar.
           llUnSit(llGetLinkKey(links)); // Use the key of the last link to be added (the avatar) to call llUnSit().
           else
           llOwnerSay("Some kind of linking or unlinking has changed me but, I am not being sat on.");
           // llUnSit() triggers the changed event too (the number of links is reduced by 1).
       }
   }
}</lsl>

See Also

Events

•  changed

Functions

•  llAvatarOnSitTarget
•  llSitTarget

Deep Notes

Search JIRA for related Issues

Signature

function void llUnSit( key id );