1
0
mirror of https://github.com/osmarks/random-stuff synced 2024-10-31 19:06:15 +00:00
random-stuff/computercraft/ni-position-approximator.lua

25 lines
577 B
Lua
Raw Permalink Normal View History

2023-11-13 19:37:05 +00:00
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)