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
Elevator Two Floor keyframed elevator  

Two Floor keyframed elevator


This is a simple 2 floor elevator, consisting of 3 scripts, one for the elevator itself, another for the elevator
call button, and a 3rd for the elevator door to open and close. The door in this case is a hollowed cylinder,
giving a slightly futuristic look. Operation is intuitive and simple: Just stand on the elevator, and it will
go up (or down) as necessary. If the elevator is not on your floor, the door will be closed and you will need
to press the call button.
The elevator is a simple, flattened disk, and the assumption going forward is the elevator will be a flattened
prim you step onto.
originally found at http://www.sluniverse.com/php/vb/script-library/68363-2-floor-key-framed-elevator.html

Category: Elevator
By : Soen Eber
Created: 2014-12-04 Edited: 2014-12-04
Worlds: Second Life

the Zip file

Download all files for Two Floor keyframed elevator
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. call button.lsl
Get file # 2. door script.lsl
1
2 // While operation is simple, there are enough complexities in the setup that you should probably have some experience
3 // with building and scripting, or have a friend available who is.
4
5 // Setup requires the following steps:
6
7 // 1. Edit the DESCRIPTION field of the prim or prims containing the elevator script to the word "setup" (without quotes),
8 // and then reset the script using tools -> reset. If the elevator is more than one prim, make sure the script is in the
9 // root prim. THE ELEVATOR SHOULD NOT BE LINKED TO ANYTHING ELSE or strangeness will occur.
10
11 // 2. Follow the prompt to move the elevator to the first floor location, and then reset again with tools -> reset.
12 // You will be prompted to move the elevator to the 2nd floor location. Once you have done so, reset the script
13 // again with tools -> reset.
14
15 //3. Place the prim or prims containing the elevator call script on each floor. For the 1st floor change the
16 // DESCRIPTION to "1" (no quotes) and to "2" (again, no quotes) for the 2nd floor. If you link the prim(s//)
17 // containing the call button to anything, its probably not a good idea to make the prim with the call script
18 // in it a root prim or strangeness will occur.
19
20 // 4. (optional) Place the prim or prims containing the elevator door script on each floor, changing the
21 // description as you did for the prim containing the call script. The door in this case will be a hollowed cylinder,
22 // hollowed to 95% with a path cut from .375 to .625. If you want a rectangular, non-curved door or a double door
23 // that opens from the center, you will have to roll your own script or get someone to write it for you,
24 // using the existing elevator door script as a template.
25
26 float wait;
27 integer ch = -11;
28 integer floor_start;
29 integer floor_dest;
30 vector pos_1;
31 vector pos_2;
32 vector elevator_scale;
33 float scan_radius;
34 string context;
35
36 calc_start()
37 {
38 if(llVecDist(llGetPos(), pos_1) < 0.5) floor_start = 1;
39 else if(llVecDist(llGetPos(), pos_2) < 0.5) floor_start = 2;
40 }
41 calc_dest()
42 {
43 if(floor_start == 1) floor_dest = 2;
44 else floor_dest = 1;
45 }
46 go()
47 {
48 float move;
49 vector v = llGetPos();
50 if(floor_dest == 1) move = pos_1.z - v.z;
51 if(floor_dest == 2) move = pos_2.z - v.z;
52 if(llFabs(move) > 1.5) llWhisper(ch, (string)floor_start+" depart");
53 wait = 2.5;
54 context = "moving";
55 llSetKeyframedMotion([<0,0,move>,ZERO_ROTATION,2],[]);
56 }
57 get_floor_pos()
58 {
61 llWhisper(0,"floor 1="+(string)pos_1);
63 llWhisper(0,"floor 2="+(string)pos_2);
64 llWhisper(0,"If these are not the correct positions, please change the elevator description to 'reset' (no quotes),");
65 llWhisper(0,"reset its script using Tools -> Reset Scripts in Selection, and follow the prompts");
66 }
67 get_set_floor_pos()
68 {
70 if(s == "reset") {
71 llWhisper(0, "Please move the elevator floor to first floor starting position, "
72 + "and then reset its script using Tools -> Reset Scripts in Selection"
73 );
74 llSetObjectDesc("setup");
75 }
76 else if(s == "setup") {
77 s = "1="+(string)llGetPos();
78 llWhisper(0,"Setting first floor to "+s);
79 llWhisper(0,"Now please move the elevator floor to the second floor starting position and reset the script");
81 }
82 else if(llSubStringIndex(s,"2=") == -1) {
83 s+=(";2="+(string)llGetPos());
84 llWhisper(0,"Setting desc to "+s);
86 get_floor_pos();
87 }
88 else {
89 get_floor_pos();
90 }
91 }
92 default
93 {
95 {
96 llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_CONVEX]);
97 elevator_scale = llGetScale();;
98 if(elevator_scale.x >= elevator_scale.y) scan_radius = elevator_scale.x;
99 else scan_radius = elevator_scale.y;
100 get_set_floor_pos();
101 state operate;
102 }
103 }
104 state operate
105 {
107 {
108 llListen(ch,"",NULL_KEY,"");
109 if(context == "moving") {
110 llWhisper(ch, (string)floor_dest+" arrived");
111 context = "exiting";
112 wait = 3;
113 state idle;
114 }
115 else if(context == "exiting") {
116 context = "";
117 }
118 }
119 sensor(integer num_detected)
120 {
121 vector va = llDetectedPos(0);
122 vector ve = llGetPos();
123 if(va.x < ve.x+(scan_radius/2) && va.x > ve.x-(scan_radius/2)) {
124 if(va.y < ve.y+(scan_radius/2) && va.y > ve.y-(scan_radius/2)) {
125 if(va.z > ve.z) {
126 calc_start();
127 calc_dest();
128 go();
129 state idle;
130 }
131 }
132 }
133
134 }
135 no_sensor()
136 {
138 }
139 collision_start(integer num_detected)
140 {
141 llSensorRepeat("",llDetectedKey(0),AGENT_BY_LEGACY_NAME,scan_radius,PI,1);
142 }
143 listen(integer ch,string name,key id,string msg)
144 {
145 if(llListFindList(["1 call","2 call"],[msg]) != -1) {
146 calc_start();
147 floor_dest = (integer)llGetSubString(msg,0,0);
148 go();
149 state idle;
150 }
151 }
152 }
153 state idle
154 {
156 {
157 llSleep(wait);
158 state operate;
159 }
160 }

Two Floor keyframed elevator

Two floor key frame elevator door Call Script (for 2 floors)
Write the floor number (1 or 2) in the description

Category: Elevator
By : Soen Eber
Created: 2014-12-04 Edited: 2014-12-04
Worlds: Second Life

1 integer ch = -11;
2 integer floor;
3 integer ready = TRUE;
4 status(integer flg)
5 {
6 ready = flg;
7 llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_FULLBRIGHT,ALL_SIDES, flg]);
8 }
9 default
10 {
12 {
13 llListen(ch,"",NULL_KEY,"");
14 floor = (integer)llGetObjectDesc();
15 }
16 listen(integer ch,string name,key id,string msg)
17 {
18 if(llSubStringIndex(msg,"arrived") != -1) {
19 llSleep(3);
20 status(TRUE);
21 }
22 else if(msg == (string)floor+" depart") {
23 status(FALSE);
24 }
25 }
26 touch_start(integer total_number)
27 {
28 if(ready == TRUE) llWhisper(ch, (string)floor+" call");
29 else llWhisper(0, "Please Wait");
30 }
31 }

Two Floor keyframed elevator

Two floor key frame elevator door script

Category: Elevator
By : Soen Eber
Created: 2014-12-04 Edited: 2014-12-04
Worlds: Second Life

1 integer ch = -11;
2 integer floor;
3 open()
4 {
5 llSetLinkPrimitiveParamsFast(
6 LINK_THIS,[PRIM_TYPE,PRIM_TYPE_CYLINDER,PRIM_HOLE_CIRCLE,<0.375,0.4,0.0>,0.95,<0,0,0>,<1,1,0>,<0,0,0>]
7 );
8 }
9 close()
10 {
11 llSetLinkPrimitiveParamsFast(
12 LINK_THIS,[PRIM_TYPE,PRIM_TYPE_CYLINDER,PRIM_HOLE_CIRCLE,<0.375,0.625,0.0>,0.95,<0,0,0>,<1,1,0>,<0,0,0>]
13 );
14 }
15 default
16 {
18 {
19 floor = (integer)llGetObjectDesc();
20 llListen(ch,"",NULL_KEY,"");
21 }
22 listen(integer ch,string name,key id,string msg)
23 {
24 if(msg == (string)floor+" arrived") {
25 open();
26 }
27 else if(msg == (string)floor+" depart") {
28 close();
29 }
30 }
31 }

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