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
Door Multi_User_Lockable_Door  

Multi_User_Lockable_Door

Multi User Lockable Door by Meiyo Sojourner.lsl

Category: Door
By : Meiyo Sojourner
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Multi_User_Lockable_Door
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Multi_User_Lockable_Door_by_Meiyo_S_1.lsl
1
2 // Nifty Neato Multi User Lockable Door, A Red Visions Script
3 // Copyright (C) 2004 Meiyo Sojourner
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 // (Also available at http://www.gnu.org/copyleft/gpl.html)
19 //
20 // WARNING: Removal of the introduction warning message will corrupt the script.
21 //
22 // Additional Credits:
23 //~~~~~~~~~~~~~~~~~~~~~
24 // Default door open/close operation from a script by Kyle Chaos
25
26
27
28 //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
29 //This door will take commands from anyone on it's authorized list
30 //
31 //It has two modes, locked and unlocked.
32 //- locked mode: only users on the authorized list can open the door
33 //- unlocked mode: anyone and their brother can open the door
34 //The door is initially set to unlocked mode.
35 //
36 //When the script is first rezzed it will reset itself.
37 //
38 //The authorized list is initially completely empty.
39 //Soon after the object containing the script is rezzed, the name of
40 //the owner is retrieved from the servers and added to the
41 //authorized list. This usually takes only a second if that.
42 //After that is done, the owner can continue with setup.
43 //
44 //To open the door... simply click on it.
45 //The door will stay open for the time specified by the script's
46 //variable 'open_time' (which can be changed by voice command)
47 //or it can be closed by clicking on it again.
48 //
49 //The 'open_time' variable is also the amount of time the door
50 //will listen for commands. Once this time expires, you must
51 //click the door again before you can issue any other commands.
52 //Closing the door manually does not stop the listening; it will
53 //keep listening for the time specified by 'open_time'. The reason
54 //for this is to cut down on the drain on the server... especially in
55 //talkative areas.
56 //A user can issue commands to the door if and only if they are on
57 //the door's authorized list.
58 //When adding users to the authorized list, make sure to get the
59 //caps right. For example, adding "joeschmo linden" will not let
60 //JoeSchmo Linden have full access to the door.
61 //
62 //For a list of commands, say "show help" in the chat window after
63 //clicking on the door.
64 //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
65
66
67
68
69 //GLOBALS
70 //=======
71 // For the messages, use %nn% in place of the name
72 // of the av that clicked on the door.
73 // Set the variable to "" to disable the message.
74 string startup_message =
75 "Touch door and say 'show help' in the chat for a list of commands";
76 string open_message = "%nn% is at the door.";
77 string close_message = "";
78 string lock_message = "Sorry %nn%, this door is locked";
79 float open_time = 30.0;
80 string open_sound = ""; // Put here the Sound s Name "Sound Name" and drop the Sound in the Same Object than this Script. Leave it this way "" for Silent.
81 string close_sound = ""; // Put here the Sound s Name "Sound Name" and drop the Sound in the Same Object than this Script. Leave it this way "" for Silent.
82 integer debug_messages = FALSE;
83 //- - - - - - - - - - - - - - - -
84 list auth_list = [];
85 integer door_open = FALSE;
86 integer locked = FALSE;
87 integer listen_tag = -1;
88 float interval = 30.0;
89 list help_message = [
90 "**Multi User Lockable Door Commands List **",
91 " 'show help' - Displays this file",
92 " 'lock' - Sets the door to Locked mode",
93 " 'unlock' - Sets the door to Unlocked mode",
94 " 'add [name]' - Replace [name] with the av you want to add to the list",
95 " 'remove [name]' - Replace [name] with an av you want to delete",
96 " 'say list' - Shows who is on the All Access list",
97 " 'change time [time]' - Replace [time] with the number of seconds",
98 " you want the door to stay open and listen."
99 ];
100
101
102 //TOOL FUNCTIONS
103 //==============
104 float debug(string m) // Allows for debug messages
105 { // to be easily turned on/off
106 if(debug_messages)
107 llSay(0,m);
108 return TRUE;
109 }
110 integer k = FALSE;
111 //- - - - - - - - - - - - - - - -
112 float debugList(list l) // List version of the
113 { // debug() function
114 string s = "";
115 if(debug_messages){
116 integer i;
117 for (i = 0; i < llGetListLength(l); i++){
118 s += llList2String(l,i);
119 if(i < llGetListLength(l) - 1)
120 s += ", ";
121 }
122 if(s == "") {
123 llSay(0,"LIST IS EMPTY");
124 }else{
125 llSay(0,s);
126 }
127 }
128 return TRUE;
129 }
130 //- - - - - - - - - - - - - - - -
131 integer q(){
132 llSay(0,"This script is provided free of charge.
133 Please contact Meiyo Sojourner if you paid for it.");
134 return TRUE;
135 }
136 //- - - - - - - - - - - - - - - -
137 integer d(){
138 llSay(0,"This script has been unacceptably modified!
139 It is now deleting itself.");
141 return TRUE;
142 }
143 //- - - - - - - - - - - - - - - -
144 float sayList(list l) // Dumps the contents of
145 { // the list into the chat
146 string s = "";
147 integer i;
148 for (i = 0; i < llGetListLength(l); i++){
149 s += llList2String(l,i);
150 if(i < llGetListLength(l) - 1)
151 s += ", ";
152 }
153 if(s == "") {
154 llSay(0,"LIST IS EMPTY");
155 }else{
156 llSay(0,s);
157 }
158 return TRUE;
159 }
160 //- - - - - - - - - - - - - - - -
161 float sayList2(list l) // Dumps the contents of the list
162 { // into the chat one line at a time
163 integer i;
164 for (i = 0; i < llGetListLength(l); i++){
165 llSay(0,llList2String(l,i));
166 }
167 return TRUE;
168 }
169 //- - - - - - - - - - - - - - - -
170 integer isIn(list test_list, list test_item) // Looks for test_item
171 { // in test_list
172 integer i;
173 for (i = 0; i < llGetListLength(test_list); i++){
174 if(llList2String(test_item, 0) == llList2String(test_list, i))
175 return TRUE;
176 }
177 return FALSE;
178 }
179 //- - - - - - - - - - - - - - - -
180 string replace(string main, string old, string new) // Search and replace
181 { // function for strings
182 string temp = "";
183 list m = llParseString2List(main,["%"],[]);
184 integer i;
185 for(i = 0; i < llGetListLength(m); i ++){
186 string c = llList2String(m,i);
187 if(c == old){
188 temp += new;
189 }else{
190 temp += c;
191 }
192 }
193 return temp;
194 }
195 //- - - - - - - - - - - - - - - -
196
197 float stopListening() // Kills the listen function
198 { // in order to save resources
199 if(listen_tag != -1)
200 llListenRemove(listen_tag);
201 listen_tag = -1;
202 return TRUE;
203 }
204 //- - - - - - - - - - - - - - - -
205 float removeName(string target_name) // Searches for and deletes
206 { // target_name from auth_list
207 integer i;
208 for (i = 0; i < llGetListLength(auth_list); i++){
209 if(target_name == llList2String(auth_list, i)){
210 auth_list = llDeleteSubList(auth_list, i, i);
211 return TRUE;
212 }
213 }
214 return FALSE;
215 }
216 //- - - - - - - - - - - - - - - -
217 integer open(string av_name) // Opens the door.
218 {
219 if(open_sound != "")
220 llTriggerSound(open_sound, 0.5);
221 if(open_message != "")
222 llSay(0, replace(open_message,"nn",av_name));
223 // vv Replace this snippet with custom code to close the door vv
224 rotation rot = llGetRot();
225 rotation delta = llEuler2Rot(<0,0,PI/4>);
226 rot = delta * rot;
227 llSetRot(rot);
228 llSleep(0.25);
229 rot = delta * rot;
230 llSetRot(rot);
231 // ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
232 return TRUE;
233 }
234 //- - - - - - - - - - - - - - - -
235 integer close(string av_name) // Closes the door.
236 {
237 if(close_sound != "")
238 llTriggerSound(close_sound, 0.5);
239 if(close_message != "")
240 llSay(0, replace(close_message,"nn",av_name));
241 // vv Replace this snippet with custom code to close the door vv
242 rotation rot = llGetRot();
243 rotation delta = llEuler2Rot(<0,0,-PI/4>);
244 rot = delta * rot;
245 llSetRot(rot);
246 llSleep(0.25);
247 rot = delta * rot;
248 llSetRot(rot);
249 // ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
250 return FALSE;
251 }
252 //- - - - - - - - - - - - - - - -
253
254
255
256
257 //CODE ENTRY
258 //==========
259 default
260 {
262 {
263 k = q();
265 }
266
267
268 dataserver(key queryid, string data) {
269 auth_list += data;
270 llSay(0,"Owner added to Authorized List.");
271 if(startup_message != "")
272 llSay(0,startup_message);
273 }
274
275
276 on_rez(integer rez)
277 {
279 }
280
281
282 touch_start(integer total_number)
283 {
284 if(!k) d();
285 list temp = [];
286 if(!door_open){
287 if(!locked){
288 door_open = open(llDetectedName(0));
289 listen_tag = llListen(0,"","","");
290 llSetTimerEvent(open_time);
291 } else if(isIn(auth_list, temp += llDetectedName(0))){
292 debug("authorized");
293 door_open = open(llDetectedName(0));
294 listen_tag = llListen(0,"","","");
295 llSetTimerEvent(open_time);
296 } else {
297 llSay(0, replace(lock_message,"nn",llDetectedName(0)));
298 }
299 } else {
300 door_open = close(llDetectedName(0));
301 }
302 debug("TEMP =");
303 debugList(temp);
304 debug("AUTH_LIST = ");
305 debugList(auth_list);
306 }
307
308
309 timer()
310 {
311 stopListening();
312 if(door_open){
313 door_open = close("the script");
314 }
315 }
316
317
318 listen(integer chan, string name, key id, string msg)
319 {
320 list temp = [];
321 if(isIn(auth_list, temp += name)){
322 list n = llParseString2List(msg, [" "], []);
323 string cmd_a = llList2String(n, 0);
324 string cmd_b = llList2String(n, 1);
325 string cmd_c = llList2String(n, 2);
326 if(cmd_a == "lock"){
327 locked = TRUE;
328 llSay(0,"Door Locked");
329 }
330 if(cmd_a == "unlock"){
331 locked = FALSE;
332 llSay(0,"Door Unlocked");
333 }
334 if(cmd_a == "add"){
335 if((cmd_b == "")||(cmd_c == "")){
336 llSay(0, "Incorrect Name Format!");
337 }else{
338 temp = [];
339 string new_name = cmd_b + " " + cmd_c;
340 if(!isIn(auth_list, temp += new_name)){
341 auth_list += new_name;
342 llSay(0, new_name + " added to list.");
343 }else{
344 llSay(0, new_name + " was already on the list.");
345 }
346 }
347 }
348 if((cmd_a == "remove")||(cmd_a == "delete")){
349 if((cmd_b == "")||(cmd_c == "")){
350 llSay(0, "Incorrect Name Format!");
351 }else{
352 string kill_name = cmd_b + " " + cmd_c;
353 if(removeName(kill_name)){
354 llSay(0,"Name Successfully Removed");
355 }else{
356 llSay(0,"Name Not Found!");
357 }
358 }
359 }
360 if((cmd_a == "say")&&(cmd_b == "list")){
361 sayList(auth_list);
362 }
363 if((cmd_a == "show")&&(cmd_b == "help")){
364 sayList2(help_message);
365 }
366 if((cmd_a == "change")&&(cmd_b == "time")){
367 float foo = llList2Float(n, 2);
368 if(foo < 10){
369 llSay(0, "Invalid Time Specified!");
370 }else{
371 open_time = foo;
372 llSay(0, "Open time changed to " + cmd_c + " seconds.");
373 }
374 }
375 }
376 }
377 }// END //

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