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 Door_Script_2  

Door_Script_2

Door Script 2.lsl

Category: Door
By : Melchoir Tokhes
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Door_Script_2
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Door_Script_2_1.lsl
1
2 // Door Script 1.0 by Melchoir Tokhes
3 // Copyright (C) 2007 Accountholder of Melchoir Tokhes(02/02/2007)
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License version 2 as published
7 // by the Free Software Foundation.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License along
15 // with this program; if not, write to the Free Software Foundation, Inc.,
16 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 //
18 // The full text of the GPL2 can be found at http://www.gnu.org/licenses/gpl.txt
19
20 // If you find this script useful and you can spare it, please consider donating
21 // a tad bit of money to me -- whatever you think is fair. Depending on my availability
22 // I will support this door. If you have any questions drop me a line.
23
24 string ACCESS_LIST = "access list"; //name of notecard containing access list
25 integer DOOR_TYPE = 1; //1 for swinging, 2 for sliding #IMPORTANT NOTE AT BOTTOM#
26 integer OPEN_METHOD = 1; //1 for touch, 2 for collision
27 float OPEN_DEGREES = 90.0; //degrees to swing open for swinging doors
28 integer NEED_ACCESS = 1; //use whitelist, 0 for no, non-0 for yes
29 float OPEN_TIME = 4.5; //time(in seconds) to stay open
30 integer DIRECTION = 1; //which way the door moves (-1 or 1)*
31 float EXPOSED_TIP = 0.1; //how much the open sliding door hangs out**
32 integer COM_CHAN = 16777; //channel used to communicate with synched doors***
33 integer TWO_PART_DOOR = 0; //set this to non-0 if the door communicates with
34 //another door to open in synch****
35 //See more notes at the bottom of this file
36 list accessList;
37 integer listCounter;
38
39 vector startingPosition;
40 rotation startingRotation;
41 vector doorScale;
42
43 key queryIDCheck;
44
45
46 close()
47 {
48 llSetRot(startingRotation);
49 llSetPos(startingPosition);
51 }
52
53 open()
54 {
55 if(DOOR_TYPE == 1){//This is for the swinging door type
56 llSetRot(startingRotation * llEuler2Rot(<0, 0, DIRECTION * OPEN_DEGREES * DEG_TO_RAD> ));
57 llSetTimerEvent(OPEN_TIME);
58 }
59
60 if(DOOR_TYPE == 2){//This is for the sliding door type
61 llSetPos(startingPosition + <0, doorScale.y * DIRECTION - (doorScale.y * DIRECTION * EXPOSED_TIP), 0>);//**
62 llSetTimerEvent(OPEN_TIME);
63 }
64 }
65
66
67 default
68 {
70 {
71 integer numberOfCards;
72 integer foundCard;
73
74 startingPosition = llGetPos();
75 startingRotation = llGetRot();
76 doorScale = llGetScale();
77 if(TWO_PART_DOOR) llListen(COM_CHAN, "", NULL_KEY, ".");
78
79 for(numberOfCards = llGetInventoryNumber(INVENTORY_NOTECARD); numberOfCards > 0; --numberOfCards)
80 if(llGetInventoryName(INVENTORY_NOTECARD, numberOfCards - 1) == ACCESS_LIST) foundCard = 1;
81 if(NEED_ACCESS){
82 if(foundCard){queryIDCheck = llGetNotecardLine(ACCESS_LIST, listCounter++);}
83 else llOwnerSay("Could not find access list");
84 }
85 }
86
87 touch_start(integer num_detected)
88 {
89 if(OPEN_METHOD == 1){
90 string accesseeCandidate = llToLower(llDetectedName(0));
91 if(NEED_ACCESS){
92 if(TWO_PART_DOOR) llWhisper(COM_CHAN, ".");
93 if(llListFindList(accessList, [accesseeCandidate]) != -1) open();
94 else llWhisper(0, "Locked.");
95 }
96 }
97 }
98
99 collision(integer num_detected)
100 {
101 if(OPEN_METHOD == 2){
102 string accesseeCandidate = llToLower(llDetectedName(0));
103 if(NEED_ACCESS){
104 if(TWO_PART_DOOR) llWhisper(COM_CHAN, ".");
105 if(llListFindList(accessList, [accesseeCandidate]) != -1) open();
106 else llWhisper(0, "Locked.");
107 }
108 }
109 }
110
111 listen(integer channel, string name, key id, string message)
112 {
113 open();
114 }
115
116 timer()
117 {
118 close();
119 }
120
121 dataserver(key queryID, string data)
122 {
123 if(queryIDCheck == queryID){
124 if(data != EOF){
125 accessList += llToLower(data);
126 queryIDCheck = llGetNotecardLine(ACCESS_LIST, listCounter++);
127 }
128 else llOwnerSay("Access list loading complete.");
129 }
130 }
131
132 }
133
134 // * For pairs of doors, typically one would need to invert the direction for the other
135 // door that corresponds. If the door is sliding on the wrong axis, move the expression
136 // that determines the movement to the other axis, either X or W, and set the other to 0
137
138 // ** This number represents how much(in factor of door width) of the door is left showing
139 // in its opened position. If the door is built using the technique of setting the cut
140 // to 0.375 - 0.875 as is done for a swinging door then be sure to add " / 2 " immediately
141 // after "doorScale.y" in the expression that determines its new position. Depending on how
142 // the door is built, you might have to use "doorScale.x" in the expression instead.
143 //
144 // It's feasable, using trickery of this number and the synched doors functionality to
145 // make multi-section telescoping doors :)
146
147 // *** This number represents the channel the door whispers on to activate the other door
148 // in a synched pair of doors. If you are using another pair of doors within this range
149 // and one pair is interfering with the other, be sure to make this channel unique to
150 // each pair of doors.
151
152 // ****This number is either 1 or -1, which reverses the direction the door moves when
153 // opened. If you are using a synched pair of doors, first get one door to open the way
154 // you want, then reverse it on the other one.
155
156 // # If you want to use the swinging door type, the door must be build as a block
157 // with a cut from 0.375 - 0.875 such that the palpable portion of the door is only
158 // half of it's true dimensions, and the true center of the door is at one edge of
159 // the palpable portion. Position the door so that this center location is at the
160 // position from which you would like the door to pivot.
161 // You may also be interested in setting the texture for the facial surfaces of
162 // the door as 2 repeats per face and 0.5 offset on the X axis.
163 // END //

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