I didn't use round, as the craft always wobbles a little. So I used format{0:n3} to cut the number. But format{0:n3} adds a thousands separator. My new version with format{0:f3} doesn't add a thousands separator and works fine.
The unexpected problem comes up, when you add two numbers, one without and one with a thousands separator. This results in a vector. For example you do 1200.5 + 1,200.5 = 2401.0 ... I would be fine with 2,401 or 2,401.0 or 2401 or 2401.0 but instead it results in vector(1, 200.5, 0) ... so it is not even a number anymore.
I've no answer to my question, but i found a solution for my problem, which might be helpful for others.
My calculator just sums up the flown distance with the distance from last "checkpoint". Adding these numbers leads to a long value like 123456.789 with no group seperators(float/fixed point). As I dont want to count every single mm from every vibration and bouncing of the craft I formated my added values as "format{0:n3}". As my craft is now pretty fast there are cycles, where it made more than 1000 meters from last checkpoint and "format{0:n3}" gives something like 1,234.567
Now doing 123456.789 + 1,234.567 does not simply give 124,691.356. It returns a vector like (1, 234.567, 0). This does not make sense at all, but thats what vizzy does.
In the end I changed my calculation from 'n' to 'f' and it works.
In Vizzy operators at the bottom just before true and false there is an operator
<vector1> <function> <vector2>
One of the possible functions is <dist> which calculates the distance between two vectors in meters. Everything you now have to do is to create a while loop, in which you get the distance from you actual vector aka position to the last known position and add this to a variable which stands for your traveled distance.
As program:
$oldPosition=$Position #get starting position
$traveledDistance=0
while($true){
$distanceTraveled=$distanceTraveled+(<$oldPosition><dist><$position>)
$oldPosition=$position
wait(0.1)
}
I was seaching for a solution for my MFDs and all i found was your question, so I did this now in my new craft and it works pretty well so far. After 5000km it shows the same distance as the Exit Screen does.
I'm still optimising my craft a little, but i will upload it within the next days. Keep an eye on "X-6C Titanium Dart", if you are still interested.
@YaMomzBox420 you are very close to what I do. As program it is like:
traveleddistance=0
lastposition=positionnow
while(true){
traveleddistance=traveleddistance + format{0:f3}(lastpostion - positionnow)
lastposition=positionnow
}
I didn't use round, as the craft always wobbles a little. So I used format{0:n3} to cut the number. But format{0:n3} adds a thousands separator. My new version with format{0:f3} doesn't add a thousands separator and works fine.
The unexpected problem comes up, when you add two numbers, one without and one with a thousands separator. This results in a vector. For example you do 1200.5 + 1,200.5 = 2401.0 ... I would be fine with 2,401 or 2,401.0 or 2401 or 2401.0 but instead it results in vector(1, 200.5, 0) ... so it is not even a number anymore.
3 months agoI've no answer to my question, but i found a solution for my problem, which might be helpful for others.
My calculator just sums up the flown distance with the distance from last "checkpoint". Adding these numbers leads to a long value like 123456.789 with no group seperators(float/fixed point). As I dont want to count every single mm from every vibration and bouncing of the craft I formated my added values as "format{0:n3}". As my craft is now pretty fast there are cycles, where it made more than 1000 meters from last checkpoint and "format{0:n3}" gives something like 1,234.567
Now doing 123456.789 + 1,234.567 does not simply give 124,691.356. It returns a vector like (1, 234.567, 0). This does not make sense at all, but thats what vizzy does.
In the end I changed my calculation from 'n' to 'f' and it works.
3 months agoMaybe very late, but i found a solution for this.
In Vizzy operators at the bottom just before true and false there is an operator
<vector1> <function> <vector2>
One of the possible functions is <dist> which calculates the distance between two vectors in meters. Everything you now have to do is to create a while loop, in which you get the distance from you actual vector aka position to the last known position and add this to a variable which stands for your traveled distance.
As program:
$oldPosition=$Position #get starting position
$traveledDistance=0
while($true){
$distanceTraveled=$distanceTraveled+(<$oldPosition><dist><$position>)
$oldPosition=$position
wait(0.1)
}
I was seaching for a solution for my MFDs and all i found was your question, so I did this now in my new craft and it works pretty well so far. After 5000km it shows the same distance as the Exit Screen does.
4 months agoI'm still optimising my craft a little, but i will upload it within the next days. Keep an eye on "X-6C Titanium Dart", if you are still interested.