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
Dance DanceScript_v1  

DanceScript_v1

DanceScript v1.lsl

Category: Dance
By : Cailyn Miller
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for DanceScript_v1
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. DanceScript_v1_1.lsl
1
2 // avatar dance script v1.1
3 // say "/1 on" or "/1 off"
4 //
5 // v1.1
6 // 30/3/04
7 // clear up llListen when leaving each state, and redo them entering each
8 // state (fixes what SL v1.3 broke)
9 //
10 // v1.0
11 // written by Cailyn Miller
12 // 25/3/04
13 // for Matheyus Gallant
14
15 // this list is the dance sequence.
16 // the first part of each line is the name of the movement, the second
17 // is the amount of time before the next movement begins.
18 // so for longer pauses between moves, make the value higher, to make moves
19 // flow together, reduce the values.
20 list lstDanceAnims = [
21 "backflip", 1,
22 "fist_pump", 2,
23 "dance1", 3,
24 "dance2", 3,
25 "dance3", 1,
26 "dance4", 2,
27 "dance5", 1,
28 "dance6", 3,
29 "dance7", 3,
30 "dance8", 3,
31 "kick_roundhouse_R", 2,
32 "musclebeach", 4,
33 "punch_L", 1,
34 "punch_onetwo", 2,
35 "punch_R", 1,
36 "sword_strike_R", 2
37 // don't put a comma at the end of the last line!
38 ];
39
40 string strCurAnim;
41 integer iCurMove;
42
43 // variable for the listen number
44 integer iListenVar;
45
46 default
47 {
49 {
50 // request permission to animate the avatar
52
53 // change state
54 state off;
55 }
56
57 on_rez(integer num)
58 {
60 }
61 }
62
63 state off
64 {
66 {
67 iListenVar = llListen(1, "", "", "on");
68 }
69
70 listen(integer channel, string name, key id, string message)
71 {
72 // should only be triggered by the owner, but check anyway
73 if( id == llGetOwner() )
74 {
75 if(message == "on")
76 {
77 // change state
78 state on;
79 }
80 }
81 }
82
83 on_rez(integer num)
84 {
86 }
87
88 attach(key id)
89 {
91 }
92
94 {
95 llListenRemove(iListenVar);
96 }
97 }
98
99 state on
100 {
102 {
103 iListenVar = llListen(1, "", "", "off");
104
105 // initialise a count
106 iCurMove = 0;
107
108 // extracts the list at the current index
109 list lMove = llList2List(lstDanceAnims, iCurMove, iCurMove + 1);
110
111 // extract the anim name and sleep time
112 string strMoveName = llList2String(lMove, 0);
113 integer iMoveTime = llList2Integer(lMove, 1);
114
115 // start the first dance move
116 //llWhisper(0, strMoveName + " " + (string)iMoveTime);
117 llStartAnimation(strMoveName);
118
119 // increment count
120 iCurMove+=2;
121
122 // save dance move name
123 strCurAnim = strMoveName;
124
125 // start a timer for the correct amount of time
126 llSetTimerEvent(iMoveTime);
127 }
128
129 listen(integer channel, string name, key id, string message)
130 {
131 // should only be triggered by the owner, but check anyway
132 if( id == llGetOwner() )
133 {
134 if(message == "off")
135 {
136 // stop the current dance move
137
138 // cancel the timer
140
141 // change state
142 state off;
143 }
144 }
145 }
146
147 on_rez(integer num)
148 {
150 }
151
152 attach(key id)
153 {
155 }
156
157 timer()
158 {
159 // stop timer
160 llSetTimerEvent(0.0);
161
162 // stop the current dance move
163 llStopAnimation(strCurAnim);
164
165 // extracts the list at the current index
166 list lMove = llList2List(lstDanceAnims, iCurMove, iCurMove + 1);
167
168 // extract the anim name and sleep time
169 string strMoveName = llList2String(lMove, 0);
170 integer iMoveTime = llList2Integer(lMove, 1);
171
172 // start the first dance move
173 //llWhisper(0, strMoveName + " " + (string)iMoveTime);
174 llStartAnimation(strMoveName);
175
176 // save dance move name
177 strCurAnim = strMoveName;
178
179 // start a timer for the correct amount of time
180 llSetTimerEvent(iMoveTime);
181
182 // increment move count (if drops of the end of the list restart at 0)
183 iCurMove+=2;
184 if(iCurMove >= llGetListLength(lstDanceAnims))
185 iCurMove = 0;
186 }
187
189 {
190 llListenRemove(iListenVar);
191 }
192 }// END //

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