Skip to content

Instantly share code, notes, and snippets.

@numberlesstim
Created August 12, 2024 14:41
Show Gist options
  • Save numberlesstim/3b1620f874436a5110eac147cc159ef2 to your computer and use it in GitHub Desktop.
Save numberlesstim/3b1620f874436a5110eac147cc159ef2 to your computer and use it in GitHub Desktop.
//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