Join us in Phaze Demesnes or follow us:

Home   Show All
Category: Contributor: Creator
Speedometer Speedometer_Working_By_Jimmy_Roo  

Speedometer_Working_By_Jimmy_Roo

Speedometer Working By Jimmy Roo.lsl

Category: Speedometer
By : Jimmy Roo
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life + OpenSim

the Zip file

Download all files for Speedometer_Working_By_Jimmy_Roo
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Speedometer_Working_By_Jimmy_Roo_1.lsl
1
2 // Speedometer Working By Jimmy Roo
3 //Here is a Speedometer I made this morning, because I got bored. It will Give your speed in KPH, rounded to the nearest KPH. It works by subtracting the x, y, z values of the current pos, and the pos from 0.5 seconds ago. it then works out the horizontal distance traveled,
4
5
6 //square root of (square root of( (x1*x2) + (y1*y2) ) * square root of ( z1 * z2 )))
7
8
9
10
11 vector current;
12 vector new;
13 float xvalue;
14 float yvalue;
15 float zvalue;
16
17 default
18 {
20 {
21 vector current = llGetPos();
22 llSetTimerEvent(0.5);
23 }
24
25 timer()
26 {
27 new = llGetPos();
28 if ( new. x < current .x)
29 {
30 xvalue = current .x - new .x;
31 }
32 if ( new .x > current .x)
33 {
34 xvalue = new .x - current .x ;
35 }
36 if ( new .x == current .x)
37 {
38 xvalue = new .x - current .x ;
39 }
40
41
42 if ( new.y < current .y)
43 {
44 yvalue = current .y - new .y ;
45 }
46 if ( new .y > current .y)
47 {
48 yvalue = new .y - current .y ;
49 }
50 if ( new .y == current .y)
51 {
52 yvalue = new .y - current .y ;
53 }
54
55
56 if ( new.z < current .z)
57 {
58 zvalue = current .z - new .z ;
59 }
60 if ( new .z > current .z)
61 {
62 zvalue = new .z - current .z ;
63 }
64 if ( new .z == current .z)
65 {
66 zvalue = new .z - current .z ;
67 }
68
69 float beforevalue = llSqrt((yvalue * yvalue) + (xvalue * xvalue));
70 float aftervalue = llSqrt((beforevalue * beforevalue) + (zvalue * zvalue));
71
72 llSetText((string)llRound((7.2 * aftervalue)) + " kph", <1,0,0>, 1);
73 current = new;
74 }
75
76 }// END //