Author Topic: ETA  (Read 1595 times)

Have a flight GUI working with compass mod; it can show you the position to and distance from a tracked waypoint (red dot).

How do I calculate ETA based on the total speed and distance?


Have a flight GUI working with compass mod; it can show you the position to and distance from a tracked waypoint (red dot).

How do I calculate ETA based on the total speed and distance?
D = rt
Distance = rate * time
T = d/r
So:

Code: [Select]
function getETA(%dist,%speed)
{
    return %dist / %speed;
}

tried it already, it's definitely not in seconds

We have know idea where you're getting speed from.

$playerSpeed = mFloor(mAbs(getword(serverconnection.getcontrolob ject().getvelocity(),0)) + mAbs(getword(serverconnection.getcontrolob ject().getvelocity(),1)) + mAbs($playerZspeed));
$playerZSpeed = getword(serverconnection.getcontrolob ject().getvelocity(),2);



Why are you trying to take the absolute value of a variable that hasn't yet been assigned

Do this:
%vel = serverConnection.getControlOb ject().getVelocity();
%x = getWord(%vel, 0);
%y = getWord(%vel, 1);
%z = getWord(%vel, 2);

%speed = vectorLen(%vel);

that's not in actual order

but dist/speed using that goes insanely fast
around 5 or 6 seconds per actual second

and i can't use local variables because the GUI uses the values

%vel = serverConnection.getControlOb ject().getVelocity();
%x = getWord(%vel, 0);
%y = getWord(%vel, 1);
%z = getWord(%vel, 2);

%speed = vectorLen(%vel);

i am such an idiot
i was using the distance instead of distance/speed in the display


but it still goes crazy fast unless you move at a constant speed.

average speed, right?

i am such an idiot
i was using the distance instead of distance/speed in the display


but it still goes crazy fast unless you move at a constant speed.
Show us the code

%vel = serverConnection.getControlOb ject().getVelocity();
%x = getWord(%vel, 0);
%y = getWord(%vel, 1);
%z = getWord(%vel, 2);
%speed = vectorLen(%vel);
$wppos = getwords($trackwaypoint[$trackedpoint], 1, 2);
$wpposf = "\c3" @ mfloor(getword($wppos, 0)) SPC mfloor(getword($wppos, 1));
$wpdist = vectorDist(getwords(serverconnection.getcontrolob ject().gettransform(), 0, 1) SPC "0", $wppos SPC "0");
$wpdistf = "\c3" @ mfloor($wpdist);
$etawp = $wpdist/%speed;
$etawpf = "\c3" @ mfloor($etawp) @ "SECS";


odd, tt seems to put a space after 'getcontrolob'

$etawp = vectorDist($trackwaypoint[$trackedpoint], serverConnection.getControlOb ject().getPosition()) / vectorLen(serverConnection.getControlOb ject().getVelocity();

Those lines compressed to 1. Check if getPosition is a function or not.

$wppos and $wpdist are used in the GUI

and of course it's a function, otherwise it would just display 0 or something

the problem is if speed changes the ETA goes crazy
seems to work better in a plane, though; can probably manage
« Last Edit: June 10, 2012, 12:03:59 PM by ThinkInvisible »

the problem is if speed changes the ETA goes crazy
That problem is by design. You can try to fix it by having a delay and using the average speed instead of the concurrent one