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 DanceServer  

DanceServer

Dance Server for a prim. Insert as many copies of this script in your prim that you think you will need to match the number of dancers

Category: Dance
By : Holy Gavenkrantz
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

the Zip file

Download all files for DanceServer
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. !Dancer.lsl
Get file # 2. !Holy Server.lsl
1
2
3
4 // mods by DonJr SpeigelBlatt and Ferd Frederix
5 //This work uses content from the Second Life® LSL Script library. Copyright 2007-2009 Linden Research, Inc. Licensed under the Creative Commons Attribution-Share Alike 3.0 License
6 /* !Dancer
7
8 Created Oct 2010 by Holy Gavenkrantz
9 Insert as many copies of this script in your prim that you think you will need to match the number of dancers
10 If you sell this I have hidden code in here that will delete your head*/
11
12 integer gDialogCH; //channel the menu will use
13 integer gListener; //open a listen so the script will hear menu choices
14 integer gIndex = 0; //used in the menu system to track NEXT and PREV functions
15 integer gScriptNum; //store the script number taken from the script name here
16 key gAvKey; //store the avatar key here
17 list gDanceList; //store the list of dance animations here
18 string gDance; //store the current dance here
19 integer gCount_limit = 9 ; // number of menu items
20
21 menu( list button_list )//le menu
22 {
23 integer items = llGetListLength(button_list);
24 string dialog_text = "\nSelect a Dance";
25 list button;
26 integer count = 0;
27 string check_item = "foo";
28 while( check_item != "" )//compile buttons and descriptions
29 {
30 check_item = llList2String(button_list, gIndex + count);
31 if( check_item != "" )
32 {
33 if( count < gCount_limit )
34 {
35 ++ count;
36 string count_item = (string)( count + gIndex) + ".";
37 dialog_text += "\n" + count_item + " " + check_item;
38 button += (string)( count + gIndex); }
39 else
40 {
41 check_item = "";
42 }
43 }
44 }
45 integer dumb_button;//fill in the spaces with "-"
46 integer i;
47 if( count > 3 && count < 6 )
48 {
49 dumb_button = 6 - count;
50 }
51 if( count > 6 && count < 9 )
52 {
53 dumb_button = 9 - count;
54 }
55 if( count > 10 && count < 12 )
56 {
57 dumb_button = 12 - count;
58 }
59 for ( i = 0; i < dumb_button; ++ i )
60 {
61 button += "-";
62 }
63 button = llList2List(button, -3, -1) + llList2List(button, -6, -4)
64 + llList2List(button, -9, -7) + llList2List(button, -12, -10);//flip the list
65 if( gIndex + gCount_limit < items )//add the next, previous and cancel buttons
66 {
67 button = "Next >>" + button;
68 }
69 else if( gIndex + gCount_limit >= items && items > gCount_limit )//wrap back to start of list
70 {
71 button = "Start >>" + button;
72 }
73 else
74 {
75 button = "-" + button;
76 }
77 button = "Cancel" + button;
78 if( gAvKey == llGetOwner() ) button = "Reset" + button;
79 if( gIndex > 0 )
80 {
81 button = "<< Prev." + button;
82 }
83 else if( gIndex == 0 && items > gCount_limit )//wrap to the end of list
84 {
85 button = "<< End" + button;
86 }
87 else
88 {
89 button = "-" + button;
90 }
92 llListenRemove(gListener);
93 gListener = llListen(gDialogCH, "", gAvKey, "");
94 llDialog(gAvKey, dialog_text, button, gDialogCH);//send the menu
95 }
96
97 default
98 {
99 changed(integer change)
100 {//this probably isn't required because the natural operation of the script resets it anyway
101 if( change & CHANGED_OWNER )
102 {
104 }
105 }
106
108 {
109 //create a negative integer using the scripts key
110 //assign a script number using the number at teh end of the script name
111 //shut the script off
112 gDialogCH = (integer)("0x"+llGetSubString(llGetInventoryKey(llGetScriptName()),0,6)) * -1;
113 integer name_search = llSubStringIndex(llGetScriptName(), " ");
114 gScriptNum = (integer)llGetSubString(llGetScriptName(), name_search + 1, -1);
116 llSleep(.5);
117 }
118
119 link_message(integer sender_num,integer num,string str,key id)
120 {
121 if( num == gScriptNum )
122 {
123 if( id )//if id is a valid key means the main server has passed someone touch request
124 {
125 gAvKey = id;
126 gDanceList = llParseString2List(str, [","], []);//store the list of animations
127 if( gAvKey == llGetOwner() )
128 gCount_limit = 8;
129 else
130 gCount_limit = 9;
131 menu(gDanceList);
132 }
133 else
134 {
135 llResetScript();//any other message from the server requires a reset
136 }
137 }
138 }
139
140 listen(integer channel, string name, key id, string message)
141 {
142 if( channel == gDialogCH )
143 {
145 llListenRemove(gListener);
146 if( message == "Cancel" || message == "-" )
147 {
148 if( llGetPermissionsKey() )//if already dancing just close the menu
149 {
150 gIndex = 0;
151 }
152 else //avatar changed mind. clear the avatar key and reset script
153 {
154 llMessageLinked(LINK_THIS, -5555, "cancel", gAvKey);
156 }
157 }
158 else if( message == "<< Prev." )
159 {
160 gIndex -= gCount_limit;
161 menu ( gDanceList );
162 }
163 else if( message == "Next >>" )
164 {
165 gIndex += gCount_limit;
166 menu ( gDanceList );
167 }
168 else if( message == "Start >>" )
169 {
170 gIndex = 0;
171 menu ( gDanceList );
172 }
173 else if( message == "<< End" )//go to the last page
174 {
175 if( llGetListLength(gDanceList) % gCount_limit )
176 {
177 gIndex = llGetListLength(gDanceList) - (llGetListLength(gDanceList) % gCount_limit);
178 }
179 else
180 {
181 gIndex = (llGetListLength(gDanceList) - (llGetListLength(gDanceList) % gCount_limit)) - gCount_limit;
182 }
183 menu ( gDanceList );
184 }
185 else if( message == "Dance" )
186 {
187 menu ( gDanceList );
188 }
189 else if( message == "Stop" )
190 {
191 llMessageLinked(LINK_THIS, -5555, "cancel", gAvKey);//clear avatar key
192 if( llGetPermissionsKey() )//only stop the dance if they are actually dancing
193 {
194 llStopAnimation(gDance);
195 llInstantMessage(gAvKey, "Thanks for dancing " + llKey2Name(gAvKey) + ".");
196 }
198 }
199 else if( message == "Reset" )//reset everything
200 {
201 llMessageLinked(LINK_THIS, -5555, "reset", gAvKey);
203 }
204 else if( (integer)message > 0 )//dance was selected
205 {
206 string old_dance = gDance; //store the current dance
207 gDance = llList2String(gDanceList,(integer)message -1);//load the next dance
208 if( llGetPermissions() & PERMISSION_TRIGGER_ANIMATION )//if already dancing
209 {
210 llMessageLinked(LINK_THIS, -5555, "color", gAvKey);
211 llStopAnimation(old_dance);
212 llStartAnimation(gDance);
213 }
214 else //else get permission
215 {
216 llSetTimerEvent(30);//safety net in case they never accept or deny permissions
218 }
219 }
220 }
221 }
222
224 {
225 if( perms & PERMISSION_TRIGGER_ANIMATION )//have permission - start dancing
226 {
228 llMessageLinked(LINK_THIS, -5555, "color", gAvKey);
229 llStartAnimation(gDance);
230 }
231 else //cancel everything
232 {
233 llMessageLinked(LINK_THIS, -5555, "cancel", gAvKey);
235 }
236 }
237
238 timer()
239 {// if we're here something went wrong
241 llListenRemove(gListener);
242 if( llGetAgentSize(gAvKey) )//still on the sim
243 {
244 if( llGetPermissionsKey() == NULL_KEY )//they're just standing there - reset
245 {
246 llMessageLinked(LINK_THIS, -5555, "cancel", gAvKey);
247 llInstantMessage(gAvKey, "The menu has timed out.");
249 }
250 else//they're dancing - just really slow decision makers
251 {
252 llInstantMessage(gAvKey, "The menu has timed out.");
253 }
254 }
255 else//they're gone - just reset
256 {
257 llMessageLinked(LINK_THIS, -5555, "cancel", gAvKey);
259 }
260 }
261 }
262 // End Of code

DanceServer

Dance Server

Category: Dance
By : Holy Gavenkrantz
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

1
2 /* !Holy Server
3
4 Created Oct 2010 by Holy Gavenkrantz
5 Insert this script in your prim
6 If you sell this I have hidden code in here that will delete your head*/
7
8 list gAvKeyList; //store all the keys and associated dance script numbers here
9 list gDanceList; //store all the dance animations in the prims inventory here
10 integer gActive = FALSE; //part of the dance script reset function
11
12 updatetext()//this keeps the users updated as to dance server status
13 {
14 llSetText(llGetObjectName() + "-" + (string)llGetListLength(gDanceList) + " Dances"
15 + "\nClick to start dancing!\nCurrently Dancing: " + (string)(llGetListLength(gAvKeyList) / 2)
17 + " possible slots.", <llFrand(1.0),llFrand(1.0),llFrand(1.0)>, 1);
18 }
19
20 reset_scripts()//this function resets all the individula dance scripts
21 {
22 llSetText(llGetObjectName() +"\nResetting Dance Scripts...", <llFrand(1.0),llFrand(1.0),llFrand(1.0)>, 1);
23 gActive = TRUE;
24 integer num = llGetInventoryNumber(INVENTORY_SCRIPT);//get the number of scripts
25 integer i;
26 while( i < num )
27 {
28 string script_name = llGetInventoryName(INVENTORY_SCRIPT, i);//store the script name temporarily
29 if( script_name != llGetScriptName() )//don't reset this script... just yet
30 {
31 llSetScriptState(script_name, TRUE);//turn on the dance script
32 llResetOtherScript(script_name);//reset it so it loads the data it needs to store ( it will shut itself back off)
33 }
34 ++i;//get the next script
35 }
36 llSleep(1); //this isn't required if you have 10 or more dance scripts
37 updatetext();
38 }
39
40 default
41 {
43 {
44 llSetText(llGetObjectName() +"\nLoading animations...", <llFrand(1.0),llFrand(1.0),llFrand(1.0)>, 1);
46 integer i;
47 while( i < num )//build the list of animations
48 {
50 ++i;
51 }
52 updatetext();
54 }
55
56 touch_start(integer total_number)
57 {
58 if( ! gActive ) //if gActive is false then reset all the scripts
59 {
60 reset_scripts();
61 }
62 integer i;
63 for (i = 0; i < total_number; ++i)
64 {
65 key current_key = llDetectedKey(i);
66 integer search = llListFindList(gAvKeyList,[current_key] ); // missing current_key
67 if( ~search ) //if the detected key is found they already have a dance script assigned
68 {
69 llMessageLinked(LINK_THIS, llList2Integer(gAvKeyList, search + 1),
70 llDumpList2String(gDanceList, ","), current_key);
71 }
72 else
73 {
74 gAvKeyList += current_key;//else add their key to the list
76 {//check to see if there are any positions left
77 //- if not remove their key from the list and let them know they must wait
78 llInstantMessage(current_key, "Sorry but there are no dance positions left");
79 gAvKeyList = llDeleteSubList(gAvKeyList, -1, -1);
80 }
81 else//there is an opening - find a non running script to assign to them
82 {
84 integer j;
85 while( j < num )
86 {
88 if( llGetScriptState(script_name) )//if the script name = this script goto the next one
89 {
90 ++j;
91 }
92 else
93 {
94 j = num;//stop the loop
95 llSetScriptState(script_name, TRUE);//start the dance script
96 integer name_search = llSubStringIndex(script_name, " ");//parse the script number from its name
97 integer script_num = (integer)llGetSubString(script_name, name_search + 1, -1);
98 gAvKeyList += script_num;//add the number to the key list
99 //send a message to the appropriate script containg the list of animation and the users key
100 llMessageLinked(LINK_THIS, script_num, llDumpList2String(gDanceList, ","), current_key);
101 }
102 }
103 }
104 }
105 }
106 }
107
108 link_message(integer sender_num, integer num, string msg, key id)
109 {
110 if( num == -5555 )//only do stuff if a message was sent to this number
111 {
112 if( msg == "cancel" )//if the message was cancel then delete the users key and script number from the key list
113 {
114 integer search = llListFindList(gAvKeyList, [id]); // missing id
115 if( ~search )
116 {
117 gAvKeyList = llDeleteSubList(gAvKeyList, search, search + 1);
118 }
119 }
120 else if( msg == "color" )//this means a dance was selected - start a timer ( explained in the timer function)
121 {
123 }
124 else if( msg == "reset" )//reset the system - only the owner as this capability
125 {
126 reset_scripts();
128 }
129 updatetext();
130 }
131 }
132
133 timer()
134 {
135 if( gAvKeyList )//as long as there is a key in the keylist keep checking that each user is still in the sim
136 {
137 integer len = llGetListLength(gAvKeyList);
138 integer i;
139 while( i < len )
140 {
141 if( llGetAgentSize(llList2Key(gAvKeyList, i)) )//if a valid size is returned then they are still here
142 {
143 i += 2;//check the next key
144 }
145 else//nope, they're gone remove them from the list and check the next key
146 {
147 llMessageLinked(LINK_THIS, llList2Integer(gAvKeyList, i + 1), "", "");
148 gAvKeyList = llDeleteSubList(gAvKeyList, i, i + 1);
149 len = llGetListLength(gAvKeyList);
150 }
151 }
152 updatetext();
153 }
154 else
155 {
156 llSetTimerEvent(0);//the key list is empty - stop checking
157 }
158 }
159
160
161 changed(integer change)
162 {
163 if( change & CHANGED_REGION_START )
164 {
165 reset_scripts();
167 }
168 }
169
170
171 on_rez(integer rez)
172 {
173 llResetScript();//gets the ball rolling
174 }
175 }

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