Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Sit Pose Ball
- // Created by Water Rogers for IBM/Opensource
- // Purpose
- // --------------------------------------------------------------
- // Pose Balls are popular for many applications, most noteable are
- // furniture. This script will show you the basics of how to set
- // up a pose ball ready object.
- // Requirements
- // --------------------------------------------------------------
- // A single prim is all that is necessary for this example.
- // Usage
- // --------------------------------------------------------------
- // We set up this particular object with "When Left Clicked: Sit on
- // Object" to make it easier on other users. Otherwise, you could
- // always right click and from the pie menu choose "Sit".
- // GLOBALS
- // --------------------------------------------------------------
- string g_SitText ; // The text to replace "sit" in the pie menu
- string g_Animation; // The animation we use (note that this is a default animation)
- vector g_SitOffset = <0.00, 0.00, 0.001>; // The sit offset can't be ZERO_VECTOR
- key g_LastAvatar = NULL_KEY; // Stores the last avatar to sit on the object
- // EVENTS
- // --------------------------------------------------------------
- stopAnimations()
- {
- list l=llGetAnimationList(g_LastAvatar);
- integer i;
- for(i=0;i<llGetListLength(l);i++){
- // llSay(0,"stopping "+llList2String(l,i));
- llStopAnimation(llList2String(l,i));
- }
- }
- default
- {
- state_entry()
- {
- // First we set up the sit text in the pie menu, and determine
- // where the sit offset should be.
- g_SitText = llGetObjectDesc();
- g_Animation=llGetInventoryName(INVENTORY_ANIMATION,0);
- llSetSitText(g_SitText);
- llSetAlpha(1,ALL_SIDES);
- llSitTarget(g_SitOffset, ZERO_ROTATION);
- llSetText(g_SitText,<1,1,1>,1);
- }
- changed(integer change)
- {
- // In the changed() event, we are looking for a change in the link
- // of the object. When someone sits on an object, they actually
- // become a part or link of the object, which is why this event is
- // raised. From here, we can determine who is sitting on the object
- // request permissions, animate the avatar, or stop any animations
- // if they are getting off the object.
- key id = llAvatarOnSitTarget();
- if(change & CHANGED_LINK)
- {
- if (id != NULL_KEY && g_LastAvatar == NULL_KEY)
- {
- // An avatar sat on the object. Or a link was added to the
- // object, to be more specific.
- g_LastAvatar = id;
- // Check and Request permissions from the avatar.
- if (!(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))
- {
- llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
- }
- llSetText("",<1,1,1>,1);
- llSetAlpha(0,ALL_SIDES);
- }
- // Avatar is getting off the object.
- if (id == NULL_KEY && g_LastAvatar != NULL_KEY)
- {
- // Make sure we have permissions to animate the avatar
- if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
- {
- // Since we have permissions, we will stop whatever
- // animations were applied to the avatar initialy
- llStopAnimation(g_Animation);
- }
- // Reset the script to release any permissions
- llResetScript();
- }
- }
- }
- run_time_permissions(integer perm)
- {
- if (!(perm & PERMISSION_TRIGGER_ANIMATION))
- {
- // Since the avatar is sitting, animation permissions are automaticaly
- // applied. But we still have to go through the logic in the script
- // to activate animations.
- llInstantMessage(g_LastAvatar, "Permissions are Required.");
- llUnSit(g_LastAvatar);
- }
- // Permissions were accepted, so we start the animation. If you want
- // to use a custom animation, then the animation has to be located within
- // the inventory of the object, and spelled the exact way it looks.
- //llSay(0,"starting animation "+g_Animation);
- stopAnimations();
- //llSay(0,"start "+g_Animation);
- llStartAnimation(g_Animation);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement