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
Altimeter AirSeaAltimeter  

AirSeaAltimeter

I wrote this for some friends who were new to SL, as a tutorial...then gave it away as a gift to some, since I feel it is more substantial than rating someone. I realized that it would be most substantial to share it with everyone.

Category: Altimeter
By : OoPsGalatea
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for AirSeaAltimeter
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. AirSeaAltimeter_1.lsl
1 default
2 {
4 {
5 llSetTimerEvent(.01); // How often your timer() event updates
6 }
7
8 timer()
9 {
10 vector pos = llGetPos(); // Gets your current position
11 vector size = llGetAgentSize(llGetOwner()); // Get the dimensions of your agent
12 size.z = size.z / 2.0; // Halve the height element of your agent, get altitude from feet
13 float aboveground = ((float)pos.z - llGround(<0.0,0.0,0.0>) - size.z); // Distance above ground
14 if(aboveground < 0.0) // If it thinks your feet are below ground
15 {
16 aboveground = llSqrt(aboveground * aboveground); // - flip it
17 }
18 if(aboveground < 0.09) // Check the margin of error for zeroing - you can redefine this
19 {
20 aboveground = 0.0; // Zero it out
21 }
22 vector Speed = llGetVel(); // LSL function that should be fixed in next release.
23 float RealSpeed = llVecMag(Speed); // Convert it to velocity you can use.
24 float abovewater = llWater(<0.0,0.0,0.0>) - pos.z; // difference between yourwater height
25 if(pos.z >= llWater(<0.0,0.0,0.0>)) // If at or above water
26 {
27 abovewater = llSqrt(abovewater * abovewater);
28 }
29 if(pos.z < llWater(<0.0,0.0,0.0>)) // If underwater
30 {
31 abovewater = abovewater - (abovewater * 2.0); // Push the number into the negative range
32 }
33 llSetText("Sea Lvl ALT: " + (string)abovewater + "\n" + "Grnd Lvl ALT: " + (string)(aboveground) + "\nSpeed: " + (string)RealSpeed, <1.0,0.0,0.0>, 1.0); // Emit string
34 }
35 }

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