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 Sequential_or_Random_Dance  

Sequential_or_Random_Dance

Dance.lsl was totally re-written by Ferd Frederis. This is Open Source, do with as you wish.

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

the Zip file

Download all files for Sequential_or_Random_Dance
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Sequential_or_Random_Dance_1.lsl
1
2 // Dance.lsl was totally re-written by Ferd Frederis. This is Open Source, do with as you wish.
3
4 // plays a random bunch of animations that are located in the prim inventory when it is attached or rezzed.
5
6 integer INTERVAL = 30; // how many seconds to play each dance, randomly
7
8 // just some constants, nothing here. Move on.
9
10 list dances;
11 integer WHICH; // which dance
12 integer TOTAL; // how many dances
13 integer PERMS; // current permissions
14 integer STATE; // off if flase, 1 = next dance, 2 = random
15 integer listener; // the current listener, so we can remove it.
16 integer counter; // counter for timer to auto stop listeners;
17
18 // pop up a dialog boz
19
20 dialog()
21 {
22 llListenRemove(listener);
23 integer channel = llCeil(llFrand(1000)+100 * -1);
24 listener = llListen(channel,"","","");
25 llDialog(llGetOwner(),"Choose",["Next Dance","Stop Dance","Random"], channel);
26 }
27 default
28 {
30 {
31 // load up the current animation inventory into a list
32 integer i;
34 for (i = 0; i < j; i++)
35 {
36 dances += llGetInventoryName(INVENTORY_ANIMATION,i); // add to a list
37 TOTAL++;
38 }
39 STATE = 1; // dance sequentially
40
42 }
43
44 // was rezzed or attached, start over
45 on_rez(integer param)
46 {
48 }
49 // someone added or deleted an animation. Start over and make a new list
50 changed(integer what)
51 {
52 if(what & CHANGED_INVENTORY)
54 }
55
56 timer()
57 {
58 // since they may hit ignore on the dialog, we count two passes at the timer, then kidll off any listener.
59 if(listener)
60 counter++;
61 if(counter)
62 llListenRemove(listener); // remove the listener after two passes to help with lag
63
64 // now lets see what to do
65 PERMS = llGetPermissions();
67 {
68 if(STATE == 1) // sequential play
69 {
70 llStopAnimation(llList2String(dances, WHICH)); // quit the current
71 WHICH++;
72 if(WHICH >= TOTAL)
73 {
74 WHICH = 0;
75 }
76 llStartAnimation(llList2String(dances, WHICH)); // start next one.
77 llOwnerSay("Dance:" + llList2String(dances, WHICH));
78 }
79 else if(STATE == 2) // random play
80 {
81
82 llStopAnimation(llList2String(dances, WHICH));
83 WHICH = llCeil(llFrand(TOTAL))-1;
84 llStartAnimation(llList2String(dances, WHICH));
85 llOwnerSay("Dance:" + llList2String(dances, WHICH));
86 }
87 llSetTimerEvent(INTERVAL);
88 }
89 else
90 {
91 // dang, no permissions, oh well, ask for them
93 }
94
95 }
96 listen(integer channel, string name, key id, string message)
97 {
98 llListenRemove(listener); // save lag
99 PERMS = llGetPermissions();
100
101 if(message == "Stop Dance")
102 {
103 STATE = FALSE;
105 {
106 llStopAnimation(llList2String(dances, WHICH));
107 }
108 llSetTimerEvent(0); // shit it all down
109 }
110 else if(message == "Next Dance")
111 {
113 {
115 STATE = 1; // flag ithis as sequential
116 }
117 else if( message == "Random")
118 {
120 {
122 STATE = 2; // flag this as random
123 }
124
125 }
126
128 {
129 if(llDetectedKey(0) == llGetOwner()) // only the owner can do this as we can control only one avatar at a time
130 {
131
132 dialog();
133 }
134
135 }
136
138 {
139 PERMS = perm;
140 llSetTimerEvent(1.0); // trigger the logic in one second
141 }
142
143 } // END //

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