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 slide_door  

slide_door

slide door.lsl

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

the Zip file

Download all files for slide_door
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. slide_door_1.lsl
1
2 key owner;
3 // Will be used to retrieve owner's key.
4
5 integer iChan = 1000;
6 // Channel door will listen on if other doors are touched;
7 // also the channel this door will broadcast on.
8
9 integer iSteps = 15;
10 // How many steps the door will open in, used to provide the
11 // illusion of sliding. Fewer steps means it opens faster,
12 // but more steps will make it "slide" smoother.
13
14 vector vOffset = <0.0, 0.15, 0.0>;
15 // Indicates how far the door will move with each step.
16 // Multiply by iSteps to calculate the total distance the
17 // door will move.
18
19 vector vBase;
20 // Used to "un-stick" the door if something blocks it.
21 // Not sure if this is needed since 0.5.1, objects don't
22 // seem to block the door any more. Leaving it in just
23 // in case, though. I think attempting to edit the door
24 // while it's moving may make it stick. This will solve
25 // that problem as well.
26
27 float fOpenTime = 1.5;
28 // How long the door stays open
29
30 string sSKeyword = "open1";
31 // Keyword door broadcasts when it's touched, to make
32 // other doors open. You can chain these to make multiple
33 // doors open when any one is touched.
34 // NEVER make sSKeyword and sRKeyword the same, or you may
35 // get some doors stuck in an infinite loop, continuously
36 // re-triggering each other.
37
38 string sRKeyword = "open2";
39 // Keyword door listens for from other doors. Will open
40 // when it "hears" this keyword.
41 // Again, NEVER make sSKeyword and sRKeyword the same.
42
43 integer bMove = FALSE;
44 // Is the door moving?
45
46 integer bLock = FALSE;
47 // Is the door locked?
48
49 integer bVerbose = FALSE;
50 // Confirm when owner locks/unlocks the door.
51
52 //*********************************************
53 // open() -- the meat and taters of the code,
54 // makes the door actually move.
55 //*********************************************
56 open()
57 {
58 bMove = TRUE;
59 integer i;
60 vector basepos = llGetPos();
61 for (i = 0; i < iSteps; i++)
62 {
63 llSetPos(basepos + i*vOffset);
64 }
65 vOffset *= -1;
66 llSleep(fOpenTime);
67 basepos = llGetPos();
68 for (i = 0; i < iSteps; i++)
69 {
70 llSetPos(basepos + i*vOffset);
71 }
72 vOffset *= -1;
73 if(llGetPos() != vBase) {
75 } else {
76 bMove = FALSE;
77 }
78 }
79
80 default
81 {
82 //************************************************** *
83 // state_entry() -- set up our global variables and
84 // initialize the listen events.
85 //************************************************** *
87 {
88 vBase = llGetPos();
89 owner = llGetOwner();
90 llListen(0,"",owner,"");
91 llListen(iChan,"",NULL_KEY,sRKeyword);
92 }
93
94 //************************************************** *
95 // listen() -- listen for other doors opening, and
96 // if owner wants to lock/unlock doors.
97 //************************************************** *
98 listen(integer chan, string name, key id, string msg)
99 {
100 if(chan == iChan && msg == sRKeyword) {
101 if(!bMove && !bLock) open();
102 if(bLock && bVerbose) llSay(0,"Locked!");
103 }
104 if(chan == 0 && id == owner && msg == "lock") {
105 bLock = TRUE;
106 if(bVerbose) llWhisper(0,"Locked!");
107 }
108 if(chan == 0 && id == owner && msg == "unlock") {
109 bLock = FALSE;
110 if(bVerbose) llWhisper(0,"Unlocked!");
111 }
112 }
113
114 //********************************************
115 // touch_start() -- what to do when someone
116 // touches the door.
117 //********************************************
118 touch_start(integer count)
119 {
120 if(bLock) {
121 llSay(0,"Locked!");
122 } else {
123 if(!bMove) {
124 llWhisper(iChan,sSKeyword);
125 open();
126 }
127 }
128 }
129
130 //************************************************** **
131 // timer() -- this is only used to un-stick the door
132 // (see vBase definition above).
133 //************************************************** **
134 timer()
135 {
136 llSetPos(vBase);
137 if(llGetPos() == vBase) {
139 bMove = FALSE;
140 }
141 }
142 }// END //

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