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 MultiUser_Lockable_Door  

MultiUser_Lockable_Door

Multi-User Lockable Door.lsl

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

the Zip file

Download all files for MultiUser_Lockable_Door
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. MultiUser_Lockable_Door_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 //GLOBALS
30 //=======
31 // For the messages, use %nn% in place of the name
32 // of the av that clicked on the door.
33 // Set the variable to "" to disable the message.
34 string startup_message =
35 "Touch door and say 'show help' in the chat for a list of commands";
36 string open_message = "%nn% is at the door.";
37 string close_message = "";
38 string lock_message = "Sorry %nn%, this door is locked";
39 float open_time = 30.0;
40 string open_sound = "Door open"; // These can be set to ""
41 string close_sound = "Door close"; // to disable the sounds.
42 integer debug_messages = FALSE;
43 //- - - - - - - - - - - - - - - -
44 list auth_list = [];
45 integer door_open = FALSE;
46 integer locked = FALSE;
47 integer listen_tag = -1;
48 float interval = 30.0;
49 list help_message = [
50 "**Multi User Lockable Door Commands List **",
51 " 'show help' - Displays this file",
52 " 'lock' - Sets the door to Locked mode",
53 " 'unlock' - Sets the door to Unlocked mode",
54 " 'add [name]' - Replace [name] with the av you want to add to the list",
55 " 'remove [name]' - Replace [name] with an av you want to delete",
56 " 'say list' - Shows who is on the All Access list",
57 " 'change time [time]' - Replace [time] with the number of seconds",
58 " you want the door to stay open and listen."
59 ];
60
61
62 //TOOL FUNCTIONS
63 //==============
64 float debug(string m) // Allows for debug messages
65 { // to be easily turned on/off
66 if(debug_messages)
67 llSay(0,m);
68 return TRUE;
69 }
70 integer k = FALSE;
71 //- - - - - - - - - - - - - - - -
72 float debugList(list l) // List version of the
73 { // debug() function
74 string s = "";
75 if(debug_messages){
76 integer i;
77 for (i = 0; i < llGetListLength(l); i++){
78 s += llList2String(l,i);
79 if(i < llGetListLength(l) - 1)
80 s += ", ";
81 }
82 if(s == "") {
83 llSay(0,"LIST IS EMPTY");
84 }else{
85 llSay(0,s);
86 }
87 }
88 return TRUE;
89 }
90 //- - - - - - - - - - - - - - - -
91 integer q(){
92 llSay(0,"This script is provided free of charge.
93 Please contact Meiyo Sojourner if you paid for it.");
94 return TRUE;
95 }
96 //- - - - - - - - - - - - - - - -
97 integer d(){
98 llSay(0,"This script has been unacceptably modified!
99 It is now deleting itself.");
101 return TRUE;
102 }
103 //- - - - - - - - - - - - - - - -
104 float sayList(list l) // Dumps the contents of
105 { // the list into the chat
106 string s = "";
107 integer i;
108 for (i = 0; i < llGetListLength(l); i++){
109 s += llList2String(l,i);
110 if(i < llGetListLength(l) - 1)
111 s += ", ";
112 }
113 if(s == "") {
114 llSay(0,"LIST IS EMPTY");
115 }else{
116 llSay(0,s);
117 }
118 return TRUE;
119 }
120 //- - - - - - - - - - - - - - - -
121 float sayList2(list l) // Dumps the contents of the list
122 { // into the chat one line at a time
123 integer i;
124 for (i = 0; i < llGetListLength(l); i++){
125 llSay(0,llList2String(l,i));
126 }
127 return TRUE;
128 }
129 //- - - - - - - - - - - - - - - -
130 integer isIn(list test_list, list test_item) // Looks for test_item
131 { // in test_list
132 integer i;
133 for (i = 0; i < llGetListLength(test_list); i++){
134 if(llList2String(test_item, 0) == llList2String(test_list, i))
135 return TRUE;
136 }
137 return FALSE;
138 }
139 //- - - - - - - - - - - - - - - -
140 string replace(string main, string old, string new) // Search and replace
141 { // function for strings
142 string temp = "";
143 list m = llParseString2List(main,["%"],[]);
144 integer i;
145 for(i = 0; i < llGetListLength(m); i ++){
146 string c = llList2String(m,i);
147 if(c == old){
148 temp += new;
149 }else{
150 temp += c;
151 }
152 }
153 return temp;
154 }
155 //- - - - - - - - - - - - - - - -
156
157 float stopListening() // Kills the listen function
158 { // in order to save resources
159 if(listen_tag != -1)
160 llListenRemove(listen_tag);
161 listen_tag = -1;
162 return TRUE;
163 }
164 //- - - - - - - - - - - - - - - -
165 float removeName(string target_name) // Searches for and deletes
166 { // target_name from auth_list
167 integer i;
168 for (i = 0; i < llGetListLength(auth_list); i++){
169 if(target_name == llList2String(auth_list, i)){
170 auth_list = llDeleteSubList(auth_list, i, i);
171 return TRUE;
172 }
173 }
174 return FALSE;
175 }
176 //- - - - - - - - - - - - - - - -
177 integer open(string av_name) // Opens the door.
178 {
179 if(open_sound != "")
180 llTriggerSound(open_sound, 0.5);
181 if(open_message != "")
182 llSay(0, replace(open_message,"nn",av_name));
183 // vv Replace this snippet with custom code to close the door vv
184 rotation rot = llGetRot();
185 rotation delta = llEuler2Rot(<0,0,PI/4>);
186 rot = delta * rot;
187 llSetRot(rot);
188 llSleep(0.25);
189 rot = delta * rot;
190 llSetRot(rot);
191 // ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
192 return TRUE;
193 }
194 //- - - - - - - - - - - - - - - -
195 integer close(string av_name) // Closes the door.
196 {
197 if(close_sound != "")
198 llTriggerSound(close_sound, 0.5);
199 if(close_message != "")
200 llSay(0, replace(close_message,"nn",av_name));
201 // vv Replace this snippet with custom code to close the door vv
202 rotation rot = llGetRot();
203 rotation delta = llEuler2Rot(<0,0,-PI/4>);
204 rot = delta * rot;
205 llSetRot(rot);
206 llSleep(0.25);
207 rot = delta * rot;
208 llSetRot(rot);
209 // ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
210 return FALSE;
211 }
212 //- - - - - - - - - - - - - - - -
213
214
215
216
217 //CODE ENTRY
218 //==========
219 default
220 {
222 {
223 k = q();
225 }
226
227
228 dataserver(key queryid, string data) {
229 auth_list += data;
230 llSay(0,"Owner added to Authorized List.");
231 if(startup_message != "")
232 llSay(0,startup_message);
233 }
234
235
236 on_rez(integer rez)
237 {
239 }
240
241
242 touch_start(integer total_number)
243 {
244 if(!k) d();
245 list temp = [];
246 if(!door_open){
247 if(!locked){
248 door_open = open(llDetectedName(0));
249 listen_tag = llListen(0,"","","");
250 llSetTimerEvent(open_time);
251 } else if(isIn(auth_list, temp += llDetectedName(0))){
252 debug("authorized");
253 door_open = open(llDetectedName(0));
254 listen_tag = llListen(0,"","","");
255 llSetTimerEvent(open_time);
256 } else {
257 llSay(0, replace(lock_message,"nn",llDetectedName(0)));
258 }
259 } else {
260 door_open = close(llDetectedName(0));
261 }
262 debug("TEMP =");
263 debugList(temp);
264 debug("AUTH_LIST = ");
265 debugList(auth_list);
266 }
267
268
269 timer()
270 {
271 stopListening();
272 if(door_open){
273 door_open = close("the script");
274 }
275 }
276
277
278 listen(integer chan, string name, key id, string msg)
279 {
280 list temp = [];
281 if(isIn(auth_list, temp += name)){
282 list n = llParseString2List(msg, [" "], []);
283 string cmd_a = llList2String(n, 0);
284 string cmd_b = llList2String(n, 1);
285 string cmd_c = llList2String(n, 2);
286 if(cmd_a == "lock"){
287 locked = TRUE;
288 llSay(0,"Door Locked");
289 }
290 if(cmd_a == "unlock"){
291 locked = FALSE;
292 llSay(0,"Door Unlocked");
293 }
294 if(cmd_a == "add"){
295 if((cmd_b == "")||(cmd_c == "")){
296 llSay(0, "Incorrect Name Format!");
297 }else{
298 temp = [];
299 string new_name = cmd_b + " " + cmd_c;
300 if(!isIn(auth_list, temp += new_name)){
301 auth_list += new_name;
302 llSay(0, new_name + " added to list.");
303 }else{
304 llSay(0, new_name + " was already on the list.");
305 }
306 }
307 }
308 if((cmd_a == "remove")||(cmd_a == "delete")){
309 if((cmd_b == "")||(cmd_c == "")){
310 llSay(0, "Incorrect Name Format!");
311 }else{
312 string kill_name = cmd_b + " " + cmd_c;
313 if(removeName(kill_name)){
314 llSay(0,"Name Successfully Removed");
315 }else{
316 llSay(0,"Name Not Found!");
317 }
318 }
319 }
320 if((cmd_a == "say")&&(cmd_b == "list")){
321 sayList(auth_list);
322 }
323 if((cmd_a == "show")&&(cmd_b == "help")){
324 sayList2(help_message);
325 }
326 if((cmd_a == "change")&&(cmd_b == "time")){
327 float foo = llList2Float(n, 2);
328 if(foo < 10){
329 llSay(0, "Invalid Time Specified!");
330 }else{
331 open_time = foo;
332 llSay(0, "Open time changed to " + cmd_c + " seconds.");
333 }
334 }
335 }
336 }
337 }// END //

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