Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Speedometer Working By Hypottinuse

Jiminy Roo
Registered User
Join date: 25 Dec 2004
Posts: 42
01-16-2005 01:50
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,


square root of (square root of( (x1*x2) + (y1*y2) ) * square root of ( z1 * z2 )))



And here is the code:
CODE

vector current;
vector new;
float xvalue;
float yvalue;
float zvalue;

default
{
state_entry()
{
vector current = llGetPos();
llSetTimerEvent(0.5);
}

timer()
{
new = llGetPos();
if ( new. x < current .x)
{
xvalue = current .x - new .x;
}
if ( new .x > current .x)
{
xvalue = new .x - current .x ;
}
if ( new .x == current .x)
{
xvalue = new .x - current .x ;
}


if ( new.y < current .y)
{
yvalue = current .y - new .y ;
}
if ( new .y > current .y)
{
yvalue = new .y - current .y ;
}
if ( new .y == current .y)
{
yvalue = new .y - current .y ;
}


if ( new.z < current .z)
{
zvalue = current .z - new .z ;
}
if ( new .z > current .z)
{
zvalue = new .z - current .z ;
}
if ( new .z == current .z)
{
zvalue = new .z - current .z ;
}

float beforevalue = llSqrt((yvalue * yvalue) + (xvalue * xvalue));
float aftervalue = llSqrt((beforevalue * beforevalue) + (zvalue * zvalue));

llSetText((string)llRound((7.2 * aftervalue)) + " kph", <1,0,0>, 1);
current = new;
}

}
Kwipper Manimal
Registered User
Join date: 12 Jan 2005
Posts: 52
04-28-2006 10:50
Awesome script, but one question. If I wanted to convert this to Miles Per Hour instead of Kilometers Per Hour, what would the script be then?
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
04-28-2006 21:30
/54/0d/103255/1.html
_____________________
i've got nothing. ;)