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 Sky_Lift_Script  

Sky_Lift_Script

Sky Lift Script.lsl

Category: Elevator
By : Digital Dharma
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Sky_Lift_Script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Sky_Lift_Script_1.lsl
1
2 //Created By: Digital Dharma
3
4 //Sky Lift
5 //This script will give the owner of an object 2 commands to lift the object
6 //to a desired height.
7 // "up" will cause the lift to rise.
8 // "down" will cause the lift to lower.
9
10 //EDIT THESE VALUES IF NECESSARY
11 float move_amount = 250; //how many meters to lift/lower on command
12 integer say_step = 25; //how often to report the % completed
13
14
15 //NOTHING BELOW HERE NEEDS EDITING
16 //I won't comment it either so if you want to toy you'll have to figure it out!
17 vector orig_pos;
18 vector new_pos;
19
20 default
21 {
23 {
24 state idle;
25 }
26 }
27
28 state idle
29 {
31 {
32 llSay(0, "Lift is ready. Sit on a box and type \"up 250m\" or \"down 250m\" (or any other distance) to command the lift.");
33 llListen(0, "", NULL_KEY, "");
34 }
35
36 listen(integer channel, string name, key id, string message)
37 {
38 if(llGetSubString(llToLower(message), 0, 1) == "up")
39 {
40 if(id != llGetOwner())
41 {
42 llSay(0, "Sorry, only the owner of the lift can control it.");
43 }
44 else
45 {
46 if((float) llGetSubString(message, 2, -1) > 0)
47 {
48 move_amount = (float) llGetSubString(message, 2, -1);
49 }
50
51 llSay(0, "Moving up " + (string) ((integer) move_amount) + " m...");
52 orig_pos = llGetPos();
53 new_pos = <orig_pos.x, orig_pos.y, orig_pos.z + move_amount>;
54 state moving;
55 }
56 }
57 else if(llGetSubString(llToLower(message), 0, 3) == "down")
58 {
59 if(id != llGetOwner())
60 {
61 llSay(0, "Sorry, only the owner of the lift can control it.");
62 }
63 else
64 {
65 if((float) llGetSubString(message, 4, -1) > 0)
66 {
67 move_amount = (float) llGetSubString(message, 4, -1);
68 }
69
70 llSay(0, "Moving down " + (string) ((integer) move_amount) + " m...");
71 orig_pos = llGetPos();
72 new_pos = <orig_pos.x, orig_pos.y, orig_pos.z - move_amount>;
73 state moving;
74 }
75 }
76 }
77 }
78
79 state moving
80 {
82 {
83 vector last_pos = llGetPos();
84 vector current_pos;
85 integer last_percent = 0;
86
87 while(last_pos != new_pos && last_pos != current_pos)
88 {
89 current_pos = llGetPos();
90 float percent = ((orig_pos.z - current_pos.z) / (orig_pos.z - new_pos.z)) * 100;
91
92
93 if((integer) (percent - say_step) > last_percent)
94 {
95 last_percent = last_percent + say_step;
96 llSay(0, (string) last_percent + "%: " + (string) ((integer) current_pos.z) + "m/" + (string) ((integer) new_pos.z) + "m");
97 }
98 llSetPos(new_pos);
99 last_pos = llGetPos();
100 }
101
102 if(llGetPos() == new_pos)
103 {
104 llSay(0, "100%: Arriving at " + (string) ((integer) new_pos.z) + "m");
105 }
106 else
107 {
108 llSay(0, "The lift has stopped at " + (string) ((integer) last_pos.z) + "m, cannot continue in that direction.");
109 }
110
111 state arriving;
112 }
113 }
114
115 state arriving
116 {
118 {
119 state idle;
120 }
121 }// END //

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