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 Dance_Pole__Av_Mover  

Dance_Pole__Av_Mover

Dance Pole + Av Mover.lsl

Category: Animation
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Dance_Pole__Av_Mover
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Dance_Pole__Av_Mover_1.lsl
1
2 integer HIDE = FALSE; //If set to true, it will make the prim invisible when someone is on it (for use with poseballs)
3
4 integer CHANNEL; //channel for script to communicate on (generated radomly below)
5
6 vector Angle = <0,0,0>;
7 string LoadText = "Ready";
8 string Context = "Dance";
9
10 integer LISTENER; //listener placeholder to kill active listens
11
12 key AVATAR; //this will be set to the person sitting on the prim
13
14 vector POS = <0.2,-0,-0.6>;//This is the initial sit target point.
15
16 list ANIM_MENU;
17 list REF_MENU;
18 integer COUNT = 1;
19 //---- Global variables are in all caps, local variables are all lowercase, do not try to use local variables out of context. ----//
20
21 Stop_All_Animations(key avatar) //this will be called below to stop the animations playing on an avatar, before animating them with your animations.
22 {
23 list animations = llGetAnimationList(avatar);//Make a list of all the animations they are currently playing
24 integer i;
25 for(i = 0; i < llGetListLength(animations); ++i)//Set up a loop
26 {
27 llStopAnimation(llList2Key(animations, i));//Stop all the animations
28 }
29 }
30
31 PresentMenu()
32 {
34 if(num <= 11)
35 {
36 ANIM_MENU = ["Move Av"];
37 REF_MENU = ["Move Av"];
38 integer i;
39 for(i = 0; i < num; ++i)
40 {
42 if(name != "")
43 {
44 ANIM_MENU += name;
45 integer x = llStringLength(name);
46 if(x > 12)
47 {
48 name = llGetSubString(name, x - 10, x - 1);
49 }
50 REF_MENU += name;
51 }
52 }
53 }
54 else
55 {
56 ANIM_MENU = ["Previous", "Move Av", "Next"];
57 REF_MENU = ["Previous", "Move Av", "Next"];
58 integer start = (COUNT * 9) - 9;
59 integer stop = (COUNT * 9) - 1;
60 integer i;
61 for(i = start; i <= stop; ++i)
62 {
64 if(name != "")
65 {
66 ANIM_MENU += name;
67 integer x = llStringLength(name);
68 if(x > 12)
69 {
70 name = llGetSubString(name, x - 10, x - 1);
71 }
72 REF_MENU += name;
73 }
74 }
75 }
76 llSetTimerEvent(600); //Set up a timer to kill the listen if no response is received
77 CHANNEL = (integer)llFrand((2147283648) + 100000) * -1; //pick a random negative channel to communicate on
78 LISTENER = llListen(CHANNEL, "", llDetectedKey(0), "");//open a listen
79 llDialog(llAvatarOnSitTarget(), "Please choose an option", REF_MENU, CHANNEL);
80 }
81
82
83 default
84 {
85
86 state_entry()//State entry occurs whenever a script is reset, or when you make changes and save it.
87 {
88 llSitTarget(POS, ZERO_ROTATION);//set the point where the person will sit.
89 }
90 changed(integer change)//if something changed
91 {
92 if(change & CHANGED_LINK)//if the something was a link change (when an avatar sits on an object, they link to it)
93 {
94 if(llAvatarOnSitTarget() != NULL_KEY)//if someone is on me
95 {
96 AVATAR = llAvatarOnSitTarget();//Set the global variable to their key for use elsewhere.
97 if(HIDE)//if the hide feature is set to true
98 {
99 llSetAlpha(0.0, ALL_SIDES);//Make this prim invisible
100 }
101 llRequestPermissions(AVATAR, PERMISSION_TRIGGER_ANIMATION);//ask for permission to animate them (it's granted automatically if they are sitting on this, but still needs to be called for it to work.)
102 }
103 else//if something changed and noone is sitting on me
104 {
105 Stop_All_Animations(AVATAR);//call the stop all aniamtions function.
106 llSetAlpha(1.0, ALL_SIDES);//make this prim visible
107 }
108 }
109 }
110
111 run_time_permissions(integer perm)//if we have permission to do something
112 {
113 if(perm & PERMISSION_TRIGGER_ANIMATION)//and that permisson is to animate them
114 {
115 Stop_All_Animations(AVATAR);//call the stop all aniamtions function.
116 string animation = llGetInventoryName(INVENTORY_ANIMATION, 0);//find the first animation in my inventory
117 llStartAnimation(animation);//animate them with it.
118 }
119 }
120
121 touch_start(integer x)//when someone touches the object containing this script.
122 {
123 if(llDetectedKey(0) == llAvatarOnSitTarget()) //if the persosn touching this is sitting on the object
124 {
125 PresentMenu();
126 }
127 }
128
129 timer()// If they ran out of time before making a selection.
130 {
131 llListenRemove(LISTENER); //remove the listener
132 llSetTimerEvent(0); //set listen remove timer back to off
133 }
134
135
136 listen(integer ch, string name, key id, string msg)//When a response is received
137 {
138 llListenRemove(LISTENER); //remove the listener
139 llSetTimerEvent(0); //set listen remove timer back to off
140 if(msg == "Move Av")
141 {
142 llSetTimerEvent(600); //Set up a timer to kill the listen if no response is received
143 LISTENER = llListen(9, "", id, "");//open a listen
144 llInstantMessage(id, "Please type the amount to move in this format Front/Back, Left/Right, Up/Down on channel 9. For example to move your avatar down 0.25m type /9 0,0,-0.25");
145 return;
146 }
147 else if(msg == "Next")
148 {
150 MAX = MAX / 9.0;
151 integer MAXIMUM = llCeil(MAX);
152 ++COUNT;
153 if(COUNT > MAXIMUM)
154 {
155 COUNT = 1;
156 }
157 PresentMenu();
158 }
159 else if(msg == "Previous")
160 {
161 if(COUNT > 1)
162 {
163 --COUNT;
164 }
165 else
166 {
168 MAX = MAX / 10.0;
169 integer MAXIMUM = llCeil(MAX);
170 COUNT = MAXIMUM;
171 }
172 PresentMenu();
173 }
174 else if(ch == 9)
175 {
176 msg = "<"+msg+">";
177 POS += (vector)msg;
179 return;
180 }
181 else if(PERMISSION_TRIGGER_ANIMATION && id == llAvatarOnSitTarget())//if we have permisson is to animate them, and they are still sitting on this.
182 {
183 Stop_All_Animations(id);
184 integer pos = llListFindList(REF_MENU, [msg]);
185 msg = llList2String(ANIM_MENU, pos);
187 }
188 else//if we don't have permission to animate them
189 {
190 if(llAvatarOnSitTarget() != NULL_KEY)//if someone is on me
191 {
192 llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);//request permission to animate them
193 }
194 }
195 }
196 }
197 // END //

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