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 Dancer  

Dancer

Dance Server

Category: Dance
By : Ferd Frederix
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

the Zip file

Download all files for Dancer
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. dancer-864.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // Open source do with as you want license by Ferd Frederix
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 list dances;
10 integer WHICH; // which dance
11 integer TOTAL; // how many dances
12 integer PERMS; // current permissions
13 integer STATE; // off if flase, 1 = next dance, 2 = random
14 integer listener; // the current listener, so we can remove it.
15 integer counter; // counter for timer to auto stop listeners;
16
17 // pop up a dialog boz
18
19 dialog()
20 {
21 llListenRemove(listener);
22 integer channel = llCeil(llFrand(1000)+100 * -1);
23 listener = llListen(channel,"","","");
24 llDialog(llGetOwner(),"Choose",["Next Dance","Stop Dance","Random"], channel);
25 }
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 dialog();
43 }
44
45 // was rezzed or attached, start over
46 on_rez(integer param)
47 {
49 }
50
51 // someone added or deleted an animation. Start over and ake a new list and
52 changed(integer what)
53 {
54 if(what & CHANGED_INVENTORY)
56 }
57
58 timer()
59 {
60 // since they may hit ignore on the dialog, we count two passes at rthe timer, then kill off any listener.
61 if(listener)
62 counter++;
63 if(counter)
64 llListenRemove(listener); // remove the listener after two passes to help with lag
65
66 // now lets see what to do
67 PERMS = llGetPermissions();
69 {
70
71 if(STATE == 1) // sequential play
72 {
73 llStopAnimation(llList2String(dances, WHICH)); // quit the current
74 WHICH++;
75 if(WHICH >= TOTAL)
76 {
77 WHICH = 0;
78 }
79 llStartAnimation(llList2String(dances, WHICH)); // start next one.
80 llOwnerSay("Dance:" + llList2String(dances, WHICH));
81 }
82 else if(STATE == 2) // random play
83 {
84 llStopAnimation(llList2String(dances, WHICH));
85 WHICH = llCeil(llFrand(TOTAL))-1;
86 llStartAnimation(llList2String(dances, WHICH));
87 llOwnerSay("Dance:" + llList2String(dances, WHICH));
88 }
89 llSetTimerEvent(INTERVAL);
90 }
91 else
92 {
93 // dang, no permissions, oh well, ask for them
95 }
96 }
97
98
99 listen(integer channel, string name, key id, string message)
100 {
101 llListenRemove(listener); // save lag
102 PERMS = llGetPermissions();
103
104 if(message == "Stop Dance")
105 {
106 STATE = FALSE;
108 {
109 llStopAnimation(llList2String(dances, WHICH));
110 }
111 llSetTimerEvent(0); // shit it all down
112 }
113 else if(message == "Next Dance")
114 {
116 {
118 }
119 STATE = 1; // flag ithis as sequential
120 }
121 else if( message == "Random")
122 {
124 {
126 }
127 STATE = 2; // flag this as random
128 }
129 }
130
132 {
133 if(llDetectedKey(0) == llGetOwner()) // only the owner can do this as we can control only one avatar at a time
134 {
135 dialog();
136 }
137 }
138
140 {
141 PERMS = perm;
142 llSetTimerEvent(1.0); // trigger the logic in one second
143 }
144
145 }
146 // END //

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