Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Pose Balls Sit_Animation_Script  

Sit_Animation_Script

Sit Animation Script.lsl

Category: Pose Balls
By : Moopf
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Sit_Animation_Script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Sit_Animation_Script_1.lsl
1
2 //Sit Animation Script by Moopf (All Rights Reserved).
3 //THE ABOVE LINE NEEDS TO STAY WITH ANY VERSION OF THIS SCRIPT THAT YOU USE
4
5 //If you purchased this script from me you may use it as much as you like.
6 //If you didn't purchase this script from me let me know where you got it!
7
8 //Instructions
9 //This script will allow you to create an object with an animation other than the standard sitting
10 //animation. There is a notecard in this object which contains a full list of possible animations
11 //as of 1.3
12
13 //This is used to store the key of the avatar currently sitting on the object
14 key agentKey = NULL_KEY;
15
16 //When an avatar sits down we request permission to animate them, and this gets set to TRUE if we
17 //receive those permissions. The avatar isn't normally requested to give permissions with a pop up box - it just
18 //happens.
19 integer permissionResult = FALSE;
20
21 //This is the animation we want to use when the avatar sits down. A full list is in the notecard contained in this
22 //object.
23 string theAnim = "sit_ground";
24
25 //This is the text that will be shown in place of 'Sit' on the pie menu the avatar sees when they right-click on
26 //the object
27 string sitText = "Meditate";
28
29 //Sitting position. This is the X,Y and Z position of where the avatar should sit on the object,
30 //in relation to the center of the object. <0,0,0> cancels the sit position. Different objects need
31 //different sitting positions to look right, so you'll need to play with the X, Y and Z values until
32 //you are happy. You can use + or - numbers. For simplicity (so you don't have to worry about rotation,
33 //you should orient your object so that the Z axis points up and the X axis (the axis the avatar will
34 //face) points forward.
35 vector sittingPosition = <-0.1,0,0.7>;
36
37
38 //init() - runs on state_entry and on_rez
39 init()
40 {
41 //Change the text shown on the pie menu to what we've specified in sitText
42 llSetSitText(sitText);
43 //Set the position on the object that the avatar should sit. For simplicity
44 //you should orient your object with the Z axis (blue one) pointing up.
45 //The <0,0,0,1> is a quaternionrotation and if you follow the sitting
46 //position notes about axis, you won't need to touch this and it's not easy
47 //to explain!
48 llSitTarget(sittingPosition,<0,0,0,1>);
49 }
50
51 default
52 {
53 //state_entry - launches whenever the script is reset (or on change of
54 //state but this script doesn't use other states!)
56 {
57 init();
58 }
59
60 //on_rez - launches whenever the object is rezzed
61 on_rez(integer times)
62 {
63 init();
64 }
65
66 //changed - launches whenever something about the object changes, such as a new
67 //object is linked which is exactly what happens when you sit on an object!
68 changed(integer change) {
69
70 //Check to see if the number if linked objects has changed
71 if(change & CHANGED_LINK)
72 {
73 //If it has try to get the key of the avatar that's sat down.
74 key agent = llAvatarOnSitTarget();
75 //Check to see if it was an avatar and that we
76 //don't currently have an avatar sitting down.
77 if( agentKey == NULL_KEY && agent != NULL_KEY ) {
78 //OK, we now now there's an avatar sitting on this object and we have their key
79 agentKey = agent;
80 //Request permission to animate the avatar
82 } else if( agentKey != NULL_KEY && agent == NULL_KEY) {
83 //The person sitting down has got up. If we managed to get permission
84 //to animate then we need to stop the animation.
85 if(permissionResult) {
86 //Stop animating the avatar
87 llStopAnimation(theAnim);
88 }
89 //So the object is ready for the next person to sit down let's reset the script
90 //to reset everything.
92 }
93 }
94 }
95
96 //run_time_permissions - launched when llRequestPermissions is used and
97 //the script receives the result of that request
99 //Check to see if we got permission to animate the avatar
101 //Set the permission flag for use later.
102 permissionResult = TRUE;
103 //Stop the default "sit" animation
104 llStopAnimation("sit");
105 //Start the animation we want to use.
106 llStartAnimation(theAnim);
107 }
108 }
109 }// END //

Back to the Best Free Tools in Second Life and OpenSim.