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 Sliding_Door_Movement_Script  

Sliding_Door_Movement_Script

Sliding Door Movement Script.lsl

Category: Door
By : John Linden
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Sliding_Door_Movement_Script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Sliding_Door_Movement_Script_1.lsl
Get file # 2. Sliding_Door_Movement_Script_2.lsl
1 // Door Lock Script -- JohnG Linden
2
3 // To make this script open/close an actual door, the door should listen
4 // for the following messages on the following chat channel. One lock
5 // can control multiple doors if they all listen on the same channel.
6 //
7 // It is advisable for you to pick your own channel number so other locks
8 // in the area don't inadvertently open/close your door.
9 //
10 integer gLockChannel = 100;
11 string gOpenMsg = "MSG_OPEN";
12 string gCloseMsg = "MSG_CLOSE";
13 //
14 // Final note: if you need to open doors a long way from the lock, look
15 // for the functions door_open_msg() and door_close_msg() below, and
16 // change the llSay() to llShout().
17
18 // who owns this door
19 // this is changed by on_rez to whoever rezzed the door
20 string gAdministrator = "";
21
22 // who's in and who's out
23 // can be changed by the admin at runtime
24 list gAdmittedList =
25 [
26 ];
27 list gBannedList =
28 [
29 ];
30
31 // return values from permissions funcs
32 integer PERM_BANNED = -1;
33 integer PERM_NO = 0;
34 integer PERM_ADMIN = 1;
35 integer PERM_OK = 2;
36
37 // permission given to people not on any list
38 // if you just want to exclude people on the banned list and admit
39 // everyone else, set to PERM_OK
40 integer gDefaultPerm = PERM_NO;
41
42 // Note: this all would be much easier with lists that can contain lists,
43 // as people could have multiple properties hanging on them. Currently
44 // it's better than arrays but is still somewhat broken, because you have
45 // to assume a # of data fields instead of being able to traverse a list
46 // of lists.
47
48 //
49 // Helper functions here
50 //
51
52 func_debug(string str)
53 {
54 llSay(0, str);
55 }
56 debug(string str)
57 {
58 llSay(0, str);
59 }
60 say(string str)
61 {
62 llSay(0, str);
63 }
64
65 // is name on admitted list?
66 integer check_admitted_list (string name)
67 {
68 if( llListFindList(gAdmittedList, [name]) >= 0 )
69 {
70 return TRUE;
71 } else
72 {
73 return FALSE;
74 }
75 }
76
77 // is name on banned list?
78 integer check_banned_list (string name)
79 {
80 if( llListFindList(gBannedList, [name]) >= 0 )
81 {
82 return TRUE;
83 } else
84 {
85 return FALSE;
86 }
87 }
88
89 // does name have perms to open the door?
90 integer check_permission (string name)
91 {
92 say("check_permission: " + name);
93 // admin always wins (and cannot ban themselves)
94 if( name == gAdministrator ) return PERM_ADMIN;
95 // now check the plebeians
96 if( check_banned_list(name) == TRUE ) return PERM_BANNED;
97 if( check_admitted_list(name) == TRUE ) return PERM_OK;
98 // not on any lists, check default
99 return gDefaultPerm;
100 }
101
102 add_to_admitted_list (string name)
103 {
104 func_debug("add_to_admitted_list");
105
106 gAdmittedList = gAdmittedList + name;
107 }
108
109 add_to_banned_list (string name)
110 {
111 func_debug("add_to_banned_list");
112
113 gBannedList = gBannedList + name;
114 }
115
116 integer remove_from_admitted_list (string name)
117 {
118 func_debug("remove_from_admitted_list");
119
120 list lyst;
121
122 debug("admit: looking for " + name);
123
124 // search and destroy
125 integer index = llListFindList(gAdmittedList, [name]);
126 if( index >= 0 )
127 {
128 debug("admit: found " + name);
129
130 // remove entry
131 gAdmittedList = llDeleteSubList(gAdmittedList, index, index);
132 return TRUE;
133 }
134
135 // couldn't find
136 debug("admit: can't find " + name);
137 return FALSE;
138 }
139
140 integer remove_from_banned_list (string name)
141 {
142 func_debug("remove_from_banned_list");
143
144 list lyst;
145
146 debug("ban: looking for " + name);
147
148 // search and destroy
149 integer index = llListFindList(gBannedList, [name]);
150 if( index >= 0 )
151 {
152 debug("ban: found " + name);
153
154 // remove entry
155 gBannedList = llDeleteSubList(gBannedList, index, index);
156 return TRUE;
157 }
158
159 // couldn't find
160 debug("ban: can't find " + name);
161 return FALSE;
162 }
163
164 show_list (list src)
165 {
166 integer i;
167 integer len = llGetListLength(src);
168
169 for ( i = 0; i < len; ++i )
170 {
171 say(llList2String(src, i));
172 }
173 }
174
175 show_admitted_list ()
176 {
177 say("Admitted avatars:");
178 show_list (gAdmittedList);
179 }
180
181 show_banned_list ()
182 {
183 say("Banned avatars:");
184 show_list (gBannedList);
185 }
186
187 // parses incoming messages and does dirty work accordingly
188 parse_and_handle_message (string message)
189 {
190 func_debug("parse_and_handle_message");
191
192 string name;
193
194 // we only listen to admin, so no user check here
195 if( "ban " == llGetSubString(message, 0, 3) )
196 {
197 name = llGetSubString(message, 4, -1);
198 if( name != gAdministrator )
199 {
200 // note: no check for validity of usernames
201 add_to_banned_list (name);
202 remove_from_admitted_list (name);
203 say(name + " has been banned.");
204 } else
205 {
206 // error
207 say("You cannot ban yourself, Master.");
208 }
209 }
210 else if( "admit " == llGetSubString(message, 0, 5) )
211 {
212 name = llGetSubString(message, 6, -1);
213 if( name != gAdministrator )
214 {
215 add_to_admitted_list (name);
216 remove_from_banned_list (name);
217 say(name + " will now be admitted.");
218 } else
219 {
220 // error
221 say("You are already admitted, Master.");
222 }
223 }
224 else if( "forget " == llGetSubString(message, 0, 6) )
225 {
226 name = llGetSubString(message, 7, -1);
227 // remove user from ban and admit lists
228 if( remove_from_banned_list(name) )
229 {
230 say(name + "'s ban has been revoked.");
231 if( gDefaultPerm == PERM_NO )
232 {
233 say("But the current default permissions still do not allow them");
234 say("to open this door.");
235 }
236 }
237 if( remove_from_admitted_list(name) )
238 {
239 say(name + "'s access has been revoked.");
240 if( gDefaultPerm == PERM_OK )
241 {
242 say("But the current default permissions still allow them");
243 say("to open this door.");
244 }
245 }
246 }
247 else if( "list" == llGetSubString(message, 0, 3) )
248 {
249 say("Administrator: " + gAdministrator);
250 show_admitted_list();
251 show_banned_list();
252 if( gDefaultPerm == PERM_NO )
253 {
254 say("Anyone not specifically admitted is denied entry.");
255 } else
256 {
257 say("Anyone not specifically banned is allowed entry.");
258 }
259 say("Type 'help' for full command list.");
260 }
261 else if( "default admit" == llGetSubString(message, 0, 12) )
262 {
263 say("Anyone not specifically banned is now allowed entry.");
264 gDefaultPerm = PERM_OK;
265 }
266 else if( "default ban" == llGetSubString(message, 0, 10) )
267 {
268 say("Anyone not specifically admitted is now denied entry.");
269 gDefaultPerm = PERM_NO;
270 }
271 else if( "help" == llGetSubString(message, 0, 3) )
272 {
273 // list of commands
274 say("Command List:");
275 say("admit [name] -- grants access");
276 say("ban [name] -- revokes access");
277 say("list -- shows admit/ban lists");
278 say("forget [name] -- removes from admit and ban lists");
279 say("default admit -- anyone not specifically banned is admitted");
280 say("default ban -- anyone not specifically admitted is banned");
281 say("help -- this text");
282 }
283 }
284
285 // send messages to actual door
286 door_open_msg()
287 {
288 llSay(gLockChannel, gOpenMsg);
289 }
290 door_close_msg()
291 {
292 llSay(gLockChannel, gCloseMsg);
293 }
294
295 //
296 // States
297 //
298
299 default
300 {
301 on_rez(integer param) { llResetScript(); }
302
304 {
305 func_debug("default state_entry");
306 // set the owner to administrator
307 string owner = llKey2Name(llGetOwner());
308 if( owner == "" )
309 {
310 say("FATAL ERROR: no owner!");
311 }
312 gAdministrator = owner;
313 say("Door Admin: " + owner);
314 // listen for the administrator
315 llListen(0, owner, "", "");
316 // door starts out closed
317 state closed_state;
318 }
319
321 {
322 }
323 }
324
325 state closed_state
326 {
327 on_rez(integer param) { llResetScript(); }
328
330 {
331 func_debug("closed_state state_entry");
332 llPlaySound("lock_close", 0.7);
333 // tell door to close
334 door_close_msg();
335 }
336
337 touch_start(integer num_touches)
338 {
339 func_debug("closed_state touch_start");
340 // currently we only address the first touch, if multiple
341 integer i = 0;
342 // who touched us?
343 string name = llDetectedName(i);
344 // can they open the door?
345 integer perm = check_permission(name);
346 if( perm == PERM_ADMIN )
347 {
348 // Yes, master. I'd like a call to determine gender so
349 // I can say "mistress" when appropriate
350 say("Door opened, Master.");
351 state open_state;
352 } else if( perm == PERM_OK )
353 {
354 // yep
355 say("Door opened for " + name);
356 state open_state;
357 } else if( perm == PERM_BANNED )
358 {
359 // specifically denied
360 say(name + " is specifically prohibited from opening this door.");
361 } else
362 {
363 say(name + " is not permitted to open this door.");
364 }
365 }
366
367 listen(integer channel, string name, key id, string message)
368 {
369 func_debug("closed_state listen");
370 // note: we don't check name because we only listen to our admin
371 parse_and_handle_message (message);
372 }
373
375 {
376 }
377 }
378
379 state open_state
380 {
381 on_rez(integer param) { llResetScript(); }
382
384 {
385 func_debug("open_state state_entry");
386 llPlaySound("lock_open", 0.7);
387 // tell door to open
388 door_open_msg();
389 }
390
391 touch_start(integer num_touches)
392 {
393 func_debug("open_state touch_start");
394 // currently we only address the first touch, if multiple
395 integer i = 0;
396 // who touched us?
397 string name = llDetectedName(i);
398 // can they open the door?
399 integer perm = check_permission(name);
400 if( perm == PERM_ADMIN )
401 {
402 // Yes, master. I'd like a call to determine gender so
403 // I can say "mistress" when appropriate
404 say("Door closed, Master.");
405 state closed_state;
406 } else if( perm == PERM_OK )
407 {
408 // yep
409 say("Door closed for " + name);
410 state closed_state;
411 } else if( perm == PERM_BANNED )
412 {
413 // specifically denied
414 say(name + " is specifically prohibited from closing this door.");
415 } else
416 {
417 say(name + " is not permitted to close this door.");
418 }
419 }
420
421 listen(integer channel, string name, key id, string message)
422 {
423 func_debug("open_state listen");
424 // note: we don't check name because we only listen to our admin
425 parse_and_handle_message (message);
426 }
427
429 {
430 }
431 }

Sliding_Door_Movement_Script

Put this in aprim and touch it to open and close the remote door

Commands:

admit [name] -- grants access
ban [name] -- revokes access
list -- shows admit/ban lists
forget [name] -- removes from admit and ban lists
default admit -- anyone not specifically banned is admitted
default ban -- anyone not specifically admitted is banned"

Category: Door
By : John Linden
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

1 // Door Lock Script -- JohnG Linden
2
3 // To make this script open/close an actual door, the door should listen
4 // for the following messages on the following chat channel. One lock
5 // can control multiple doors if they all listen on the same channel.
6 //
7 // It is advisable for you to pick your own channel number so other locks
8 // in the area don't inadvertently open/close your door.
9 //
10 integer gLockChannel = 100;
11 string gOpenMsg = "MSG_OPEN";
12 string gCloseMsg = "MSG_CLOSE";
13 //
14 // Final note: if you need to open doors a long way from the lock, look
15 // for the functions door_open_msg() and door_close_msg() below, and
16 // change the llSay() to llShout().
17
18 // who owns this door
19 // this is changed by on_rez to whoever rezzed the door
20 string gAdministrator = "";
21
22 // who's in and who's out
23 // can be changed by the admin at runtime
24 list gAdmittedList =
25 [
26 ];
27 list gBannedList =
28 [
29 ];
30
31 // return values from permissions funcs
32 integer PERM_BANNED = -1;
33 integer PERM_NO = 0;
34 integer PERM_ADMIN = 1;
35 integer PERM_OK = 2;
36
37 // permission given to people not on any list
38 // if you just want to exclude people on the banned list and admit
39 // everyone else, set to PERM_OK
40 integer gDefaultPerm = PERM_NO;
41
42 // Note: this all would be much easier with lists that can contain lists,
43 // as people could have multiple properties hanging on them. Currently
44 // it's better than arrays but is still somewhat broken, because you have
45 // to assume a # of data fields instead of being able to traverse a list
46 // of lists.
47
48 //
49 // Helper functions here
50 //
51
52 func_debug(string str)
53 {
54 llSay(0, str);
55 }
56 debug(string str)
57 {
58 llSay(0, str);
59 }
60 say(string str)
61 {
62 llSay(0, str);
63 }
64
65 // is name on admitted list?
66 integer check_admitted_list (string name)
67 {
68 if( llListFindList(gAdmittedList, [name]) >= 0 )
69 {
70 return TRUE;
71 } else
72 {
73 return FALSE;
74 }
75 }
76
77 // is name on banned list?
78 integer check_banned_list (string name)
79 {
80 if( llListFindList(gBannedList, [name]) >= 0 )
81 {
82 return TRUE;
83 } else
84 {
85 return FALSE;
86 }
87 }
88
89 // does name have perms to open the door?
90 integer check_permission (string name)
91 {
92 say("check_permission: " + name);
93 // admin always wins (and cannot ban themselves)
94 if( name == gAdministrator ) return PERM_ADMIN;
95 // now check the plebeians
96 if( check_banned_list(name) == TRUE ) return PERM_BANNED;
97 if( check_admitted_list(name) == TRUE ) return PERM_OK;
98 // not on any lists, check default
99 return gDefaultPerm;
100 }
101
102 add_to_admitted_list (string name)
103 {
104 func_debug("add_to_admitted_list");
105
106 gAdmittedList = gAdmittedList + name;
107 }
108
109 add_to_banned_list (string name)
110 {
111 func_debug("add_to_banned_list");
112
113 gBannedList = gBannedList + name;
114 }
115
116 integer remove_from_admitted_list (string name)
117 {
118 func_debug("remove_from_admitted_list");
119
120 list lyst;
121
122 debug("admit: looking for " + name);
123
124 // search and destroy
125 integer index = llListFindList(gAdmittedList, [name]);
126 if( index >= 0 )
127 {
128 debug("admit: found " + name);
129
130 // remove entry
131 gAdmittedList = llDeleteSubList(gAdmittedList, index, index);
132 return TRUE;
133 }
134
135 // couldn't find
136 debug("admit: can't find " + name);
137 return FALSE;
138 }
139
140 integer remove_from_banned_list (string name)
141 {
142 func_debug("remove_from_banned_list");
143
144 list lyst;
145
146 debug("ban: looking for " + name);
147
148 // search and destroy
149 integer index = llListFindList(gBannedList, [name]);
150 if( index >= 0 )
151 {
152 debug("ban: found " + name);
153
154 // remove entry
155 gBannedList = llDeleteSubList(gBannedList, index, index);
156 return TRUE;
157 }
158
159 // couldn't find
160 debug("ban: can't find " + name);
161 return FALSE;
162 }
163
164 show_list (list src)
165 {
166 integer i;
167 integer len = llGetListLength(src);
168
169 for ( i = 0; i < len; ++i )
170 {
171 say(llList2String(src, i));
172 }
173 }
174
175 show_admitted_list ()
176 {
177 say("Admitted avatars:");
178 show_list (gAdmittedList);
179 }
180
181 show_banned_list ()
182 {
183 say("Banned avatars:");
184 show_list (gBannedList);
185 }
186
187 // parses incoming messages and does dirty work accordingly
188 parse_and_handle_message (string message)
189 {
190 func_debug("parse_and_handle_message");
191
192 string name;
193
194 // we only listen to admin, so no user check here
195 if( "ban " == llGetSubString(message, 0, 3) )
196 {
197 name = llGetSubString(message, 4, -1);
198 if( name != gAdministrator )
199 {
200 // note: no check for validity of usernames
201 add_to_banned_list (name);
202 remove_from_admitted_list (name);
203 say(name + " has been banned.");
204 } else
205 {
206 // error
207 say("You cannot ban yourself, Master.");
208 }
209 }
210 else if( "admit " == llGetSubString(message, 0, 5) )
211 {
212 name = llGetSubString(message, 6, -1);
213 if( name != gAdministrator )
214 {
215 add_to_admitted_list (name);
216 remove_from_banned_list (name);
217 say(name + " will now be admitted.");
218 } else
219 {
220 // error
221 say("You are already admitted, Master.");
222 }
223 }
224 else if( "forget " == llGetSubString(message, 0, 6) )
225 {
226 name = llGetSubString(message, 7, -1);
227 // remove user from ban and admit lists
228 if( remove_from_banned_list(name) )
229 {
230 say(name + "'s ban has been revoked.");
231 if( gDefaultPerm == PERM_NO )
232 {
233 say("But the current default permissions still do not allow them");
234 say("to open this door.");
235 }
236 }
237 if( remove_from_admitted_list(name) )
238 {
239 say(name + "'s access has been revoked.");
240 if( gDefaultPerm == PERM_OK )
241 {
242 say("But the current default permissions still allow them");
243 say("to open this door.");
244 }
245 }
246 }
247 else if( "list" == llGetSubString(message, 0, 3) )
248 {
249 say("Administrator: " + gAdministrator);
250 show_admitted_list();
251 show_banned_list();
252 if( gDefaultPerm == PERM_NO )
253 {
254 say("Anyone not specifically admitted is denied entry.");
255 } else
256 {
257 say("Anyone not specifically banned is allowed entry.");
258 }
259 say("Type 'help' for full command list.");
260 }
261 else if( "default admit" == llGetSubString(message, 0, 12) )
262 {
263 say("Anyone not specifically banned is now allowed entry.");
264 gDefaultPerm = PERM_OK;
265 }
266 else if( "default ban" == llGetSubString(message, 0, 10) )
267 {
268 say("Anyone not specifically admitted is now denied entry.");
269 gDefaultPerm = PERM_NO;
270 }
271 else if( "help" == llGetSubString(message, 0, 3) )
272 {
273 // list of commands
274 say("Command List:");
275 say("admit [name] -- grants access");
276 say("ban [name] -- revokes access");
277 say("list -- shows admit/ban lists");
278 say("forget [name] -- removes from admit and ban lists");
279 say("default admit -- anyone not specifically banned is admitted");
280 say("default ban -- anyone not specifically admitted is banned");
281 say("help -- this text");
282 }
283 }
284
285 // send messages to actual door
286 door_open_msg()
287 {
288 llSay(gLockChannel, gOpenMsg);
289 }
290 door_close_msg()
291 {
292 llSay(gLockChannel, gCloseMsg);
293 }
294
295 //
296 // States
297 //
298
299 default
300 {
301 on_rez(integer param) { llResetScript(); }
302
304 {
305 func_debug("default state_entry");
306 // set the owner to administrator
307 string owner = llKey2Name(llGetOwner());
308 if( owner == "" )
309 {
310 say("FATAL ERROR: no owner!");
311 }
312 gAdministrator = owner;
313 say("Door Admin: " + owner);
314 // listen for the administrator
315 llListen(0, owner, "", "");
316 // door starts out closed
317 state closed_state;
318 }
319
321 {
322 }
323 }
324
325 state closed_state
326 {
327 on_rez(integer param) { llResetScript(); }
328
330 {
331 func_debug("closed_state state_entry");
332 llPlaySound("lock_close", 0.7);
333 // tell door to close
334 door_close_msg();
335 }
336
337 touch_start(integer num_touches)
338 {
339 func_debug("closed_state touch_start");
340 // currently we only address the first touch, if multiple
341 integer i = 0;
342 // who touched us?
343 string name = llDetectedName(i);
344 // can they open the door?
345 integer perm = check_permission(name);
346 if( perm == PERM_ADMIN )
347 {
348 // Yes, master. I'd like a call to determine gender so
349 // I can say "mistress" when appropriate
350 say("Door opened, Master.");
351 state open_state;
352 } else if( perm == PERM_OK )
353 {
354 // yep
355 say("Door opened for " + name);
356 state open_state;
357 } else if( perm == PERM_BANNED )
358 {
359 // specifically denied
360 say(name + " is specifically prohibited from opening this door.");
361 } else
362 {
363 say(name + " is not permitted to open this door.");
364 }
365 }
366
367 listen(integer channel, string name, key id, string message)
368 {
369 func_debug("closed_state listen");
370 // note: we don't check name because we only listen to our admin
371 parse_and_handle_message (message);
372 }
373
375 {
376 }
377 }
378
379 state open_state
380 {
381 on_rez(integer param) { llResetScript(); }
382
384 {
385 func_debug("open_state state_entry");
386 llPlaySound("lock_open", 0.7);
387 // tell door to open
388 door_open_msg();
389 }
390
391 touch_start(integer num_touches)
392 {
393 func_debug("open_state touch_start");
394 // currently we only address the first touch, if multiple
395 integer i = 0;
396 // who touched us?
397 string name = llDetectedName(i);
398 // can they open the door?
399 integer perm = check_permission(name);
400 if( perm == PERM_ADMIN )
401 {
402 // Yes, master. I'd like a call to determine gender so
403 // I can say "mistress" when appropriate
404 say("Door closed, Master.");
405 state closed_state;
406 } else if( perm == PERM_OK )
407 {
408 // yep
409 say("Door closed for " + name);
410 state closed_state;
411 } else if( perm == PERM_BANNED )
412 {
413 // specifically denied
414 say(name + " is specifically prohibited from closing this door.");
415 } else
416 {
417 say(name + " is not permitted to close this door.");
418 }
419 }
420
421 listen(integer channel, string name, key id, string message)
422 {
423 func_debug("open_state listen");
424 // note: we don't check name because we only listen to our admin
425 parse_and_handle_message (message);
426 }
427
429 {
430 }
431 }

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