1
0
mirror of https://github.com/osmarks/random-stuff synced 2024-12-27 10:30:35 +00:00
random-stuff/computercraft/ni-position-approximator.lua
2023-11-13 19:37:05 +00:00

25 lines
577 B
Lua

local iface = peripheral.wrap "back"
local x, y, z = gps.locate()
local approx = y
local function do_approx()
local past_time = os.epoch "utc"
while true do
local time = os.epoch "utc"
local diff = (time - past_time) / 1000
past_time = time
local meta = iface.getMetaByName "gollark"
approx = approx + (meta.motionY * diff)
sleep()
end
end
local function do_gps()
while true do
local x, y, z = gps.locate()
print("real=", y, "\napprox=", approx, "\ndiff=", y - approx)
sleep(0.5)
end
end
parallel.waitForAll(do_approx, do_gps)