robot wars

This commit is contained in:
kepler155c
2018-02-05 06:20:49 -05:00
parent fc394801a1
commit 059bcbaedb
2 changed files with 24 additions and 0 deletions

24
autorun/neural.lua Normal file
View File

@@ -0,0 +1,24 @@
_G.requireInjector(_ENV)
local GPS = require('gps')
local device = _G.device
if device.neuralInterface then
function device.neuralInterface.goTo(x, _, 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)
end)
end
return false, 'No GPS'
end
end