Created
August 12, 2024 14:41
-
-
Save numberlesstim/3b1620f874436a5110eac147cc159ef2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//gist 3b1620f874436a5110eac147cc159ef2 | |
odometer on. | |
set data to lex(). | |
set data:totDist to 0. | |
set data:minDist to 1. | |
set data:last to lex("altitude", altitude, "gp", ship:geoposition). | |
if exists("1:/odometer.json") set data to readjson("1:/odometer.json"). | |
on time:second { | |
local current is lex("altitude", altitude, "gp", ship:geoposition). | |
local dist is (data:last:gp:altitudeposition(data:last:altitude) - current:gp:altitudeposition(current:altitude)):mag. | |
if dist > data:minDist { | |
set data:totDist to data:totDist + dist. | |
set data:last to current. | |
writejson(data, "1:/odometer.json"). | |
} | |
return odometer. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment