improve follow

This commit is contained in:
kepler155c@gmail.com
2019-02-12 17:04:14 -05:00
parent e0bad8edaf
commit d98ba35a21
4 changed files with 37 additions and 15 deletions

View File

@@ -1,22 +1,26 @@
_G.requireInjector(_ENV)
local GPS = require('gps')
local device = _G.device
if device.neuralInterface and device.wireless_modem then
device.neuralInterface.goTo = function(x, _, z)
local ni = require('neural.interface')
device.neuralInterface.goTo = function(x, y, z)
local pt = GPS.locate(2)
if pt then
return pcall(function()
local gpt = {
x = x - pt.x,
y = 0,
z = z - pt.z,
}
gpt.x = math.min(math.max(gpt.x, -15), 15)
gpt.z = math.min(math.max(gpt.z, -15), 15)
return device.neuralInterface.walk(gpt.x, gpt.y, gpt.z)
if false and device.neuralInterface.walk then
local gpt = {
x = x - pt.x,
y = 0,
z = z - pt.z,
}
gpt.x = math.min(math.max(gpt.x, -15), 15)
gpt.z = math.min(math.max(gpt.z, -15), 15)
return device.neuralInterface.walk(gpt.x, gpt.y, gpt.z)
else
local y, p = ni.yap(pt, { x = x, y = y + 2, z = z })
return ni.launch(y, p, 1)
end
end)
end
return false, 'No GPS'