rendered paste bodydrone = component.proxy(component.list("drone")())
nav = component.proxy(component.list("navigation")())
modem = component.proxy(component.list("modem")())
xPos,yPos,zPos = nav.getPosition()
xCorrection = 576.5
yCorrection = 0.5
zCorrection = 576.5
function goToGlobalPos(xTarget, yTarget, zTarget, xCorrection, yCorrection, zCorrection)
xPos,yPos,zPos = nav.getPosition()
moveX = xTarget - (xPos - xCorrection)
moveY = yTarget - (yPos - yCorrection)
moveZ = zTarget - (zPos - zCorrection)
drone.move(moveX, moveY, moveZ)
-- Debug, can remove
modem.broadcast(2412, "Pos: X:" .. xPos .. " Y:" .. yPos .. " Z:" .. zPos)
modem.broadcast(2412, "Move: X:" .. moveX .. " Y:" .. moveY .. " Z:" .. moveZ)
modem.broadcast(2412, "Pos: X:" .. math.floor(xPos) .. " Y:" .. yPos .. " Z:" .. math.floor(zPos))
xPos,yPos,zPos = nav.getPosition()
end
modem.open(2412)
local function respond(...)
local args = table.pack(...)
pcall(function() modem.broadcast(2412, table.unpack(args)) end)
end
local function receive()
while true do
local evt,_,_,_,_,cmd = computer.pullSignal(5)
if evt == "modem_message" then
return load(cmd)
end
end
end
while true do
local result,reason = pcall(function()
local result,reason = receive()
if not result then return respond(reason) end
respond(result())
end)
if not result then respond(reason) end
end