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 Elevator  

Elevator

Elevator

Category: Elevator
By : Encog Dod
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Elevator
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Elevator_1.lsl
1 // From the book:
2 //
3 // Scripting Recipes for Second Life
4 // by Jeff Heaton (Encog Dod in SL)
5 // ISBN: 160439000
6 X// Copyright 2007 by Heaton Research, Inc.
7 //
8 // This script may be freely copied and modified so long as this header
9 // remains unmodified.
10 //
11 // For more information about this book visit the following web site:
12 //
13 // http://www.heatonresearch.com/articles/series/22/
14
15 integer CHANNEL = 42; // dialog channel
16 list MENU_MAIN = ["Floor 1", "Floor 2", "Floor 3", "Floor 4", "Floor 5", "Floor 6", "Floor 7", "Floor 8", "Floor 9", "Floor 10","Roof"]; // the main menu
17
18 float BOTTOM = 22.260;
19 float FLOOR_HEIGHT = 10;
20 float SPEED = 2;
21 float target;
22
23
24 default
25 {
27 {
28 llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users)
29 llSitTarget(<0,-0.5,0.5>, llEuler2Rot(<0,0,-90>) );
30 llSetText("Sit Here to Ride Elevator",<0,0,0>,1.0);
31 target = BOTTOM;
32 }
33
34 listen(integer channel, string name, key id, string message)
35 {
36 integer idx = llListFindList(MENU_MAIN, [message]);
37 if( idx!=-1 )
38 {
39 llSay(0,"Elevator heading to " + message + "." );
40 target = BOTTOM + (idx*10);
41 state moving;
42 }
43 }
44
45 changed(integer Change)
46 {
47 llDialog(llAvatarOnSitTarget(), "Where to?", MENU_MAIN, CHANNEL);
48 }
49
50 }
51
52 state moving
53 {
54
55
57 {
58 llSetTimerEvent(0.1);
59 }
60
61 timer()
62 {
63 vector pos = llGetPos();
64
65 if( pos.z!=target )
66 {
67 if( pos.z>target )
68 {
69 pos.z = pos.z - SPEED;
70 }
71 else
72 {
73 pos.z = pos.z + SPEED;
74 }
75 }
76
77 if( llFabs(pos.z - target) < SPEED )
78 {
79 pos.z = target;
81 llSetPos(pos);
82 llSay(0,"Elevator has reached its target." );
83 state default;
84 }
85
86 llSetPos(pos);
87
88 }
89 }

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