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
Animation Stand MultiPoseScript  

MultiPoseScript

MultiPoseScript.lsl

Category: Animation Stand
By : Teddy Wishbringer
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for MultiPoseScript
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. MultiPoseScript_1.lsl
1
2 // Animation Stand (Stand Script)
3 // by Teddy Wishbringer
4 //
5 // Thanks go to Argent Stonecutter for assistance in streamlining and bug squishing. :)
6 //
7 // Allows owner to cycle through all the animations stored within the stand by
8 // clicking on BACK and NEXT buttons. This script goes in the stand, which
9 // should be the root prim in the linkset. Linkset requires two additional
10 // prim buttons (forward and backward) with each named 'next' and 'back' respectively.
11 //
12 // NOTE: This script is made free, and may be destributed as long as you
13 // do not charge for it, the comments remain untouched and this script
14 // remains end-user modifiable.
15
16
17 // User adjustable settings
18
19 vector animation_offset = <0,0,1.5>; // Animation offset from stand
20 string base_float_text = "Now playing animation: "; // Float text prefix
21 vector color_float_text = <1,1,1>; // Floating text colour
22 float alpha_float_text = 1.0; // Floating text alpha transparency
23
24 // System settings - Do Not Change Anything Below!
25
26 integer animation_qty; // Number of animations available
27 integer animation_current; // Inventory number of current animation
28 string animation_name; // Name of current animation
29 string new_animation_name; // Name of next animation.
30 string float_text; // Used when we evaluate the entire floating text message
31 key avatar; // Key of the avatar who's sitting on me
32
33 update_inventory()
34 {
35 llSetText("Updating animation list...", color_float_text,alpha_float_text);
36 animation_qty = llGetInventoryNumber(INVENTORY_ANIMATION); // Check how many anims we have?
37 if(animation_qty > 0)
38 {
39 llWhisper(0, "Total animations loaded in this stand: " + (string)animation_qty);
40 set_anim(0);
41 }
42 else
43 {
44 llSetText("No Animations Found.. Offline", color_float_text,alpha_float_text);
45 }
46 }
47
48 // Set the next animation available as the active one
49 set_anim(integer inventory_number)
50 {
51 // Get the name of the animation is inventory position (inventory_number)
52 new_animation_name = llGetInventoryName(INVENTORY_ANIMATION,inventory_number);
53 // Update the floating text to display new animation, and the number out of total available
54 float_text = base_float_text + new_animation_name + "\n(" + (string)(animation_current + 1) + " of " + (string)animation_qty + ")";
55 llSetText(float_text, color_float_text,alpha_float_text);
56
57 // Get the key of the avatar on the stand (or if none is present)
58 avatar = llAvatarOnSitTarget();
59
60 if(avatar != NULL_KEY) // Is avatar is still posing, if so then..
61 {
62 llStopAnimation(animation_name); // Stop current animation
63 llStartAnimation(new_animation_name); // Start next animation
64 }
65 // Set the new animation name as the current
66 animation_name = new_animation_name;
67 }
68
69 default
70 {
71
72 on_rez(integer num)
73 {
74 llResetScript(); // Reset the script
75 }
76
78 {
79 update_inventory(); // Perform an inventory update and determine how many animations we have
80
81 if(animation_qty > 0)
82 {
83 llSetSitText("Pose");
84 llSitTarget(animation_offset,ZERO_ROTATION);
85 animation_name = llGetInventoryName(INVENTORY_ANIMATION, 0);
86 set_anim(animation_current);
87 }
88
89 }
90
91 // If touched, detect touch location and do the right thing
93 {
94 // Get the name of the prim touched
96
97 if(where == "next") // The next button was pressed
98 {
99 animation_current++; // Increment the animation inventory pointer
100 if((animation_current + 1) > animation_qty) // Have we reached the last animation in the object?
101 {
102 animation_current = 0; // We have, so wrap around back to the first one
103 }
104 set_anim(animation_current);
105 }
106 else if(where == "back") // The back button was pressed
107 {
108 animation_current--; // Decrement the animation inventory pointer
109 if(animation_current < 0) // Have we reached the first animation in the object?
110 {
111 animation_current = animation_qty - 1; // We have, so wrap around to the last one
112 }
113
114 set_anim(animation_current); // Update the animation played by the stand
115 }
116 }
117
118 changed(integer change)
119 {
120 if(change & CHANGED_INVENTORY) // Test for a changed inventory
121 {
122 update_inventory();
123 }
124
125 // The object's sit target has been triggered
126 if(change & CHANGED_LINK) // Test for a changed link
127 {
128 avatar = llAvatarOnSitTarget();
129 if(avatar != NULL_KEY) // Is that changed link an avatar?
130 {
132 }
133 else
134 {
136 {
137 llStopAnimation(animation_name);
138 }
139 }
140 }
141 }
142
144 {
146 {
147 llStopAnimation("sit");
148 llStartAnimation(animation_name);
149 } // other permission checks would follow
150 }
151 }
152
153
154 // END //

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