Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function proxyFor(name, required)
- local address = component and component.list(name)()
- if not address and required then
- error("missing component '" .. name .. "'")
- end
- return address and component.proxy(address) or nil
- end
- --Require
- local drone = proxyFor("drone", true)
- local navigation = proxyFor("navigation", true)
- local m = proxyFor("modem", true)
- m.open(808)
- m.open(809)
- m.open(810)
- disX = -17
- disY = -100
- disZ = 0
- local startx, starty, startz = navigation.getPosition()
- --Initial Values
- workedx = 0
- workedy = 0
- workedz = 0
- while (workedx > disX + 1 or workedx < disX - 1) do
- m.broadcast(808, "X: " .. workedx)
- x, y, z = navigation.getPosition()
- workedx = x - startx
- if workedx < disX then
- drone.move(1,0,0)
- end
- if workedx > disX then
- drone.move(-1,0,0)
- end
- end
- while (workedz > disZ + 1 or workedz < disZ - 1) do
- m.broadcast(809, "Z: " .. workedz)
- x, y, z = navigation.getPosition()
- workedz = y - starty
- if workedz < disZ then
- drone.move(0,0,1)
- end
- if workedz > disZ then
- drone.move(0,0,-1)
- end
- end
- while (workedy > disY + 1 or workedy < disY - 1) do
- m.broadcast(810, "Y: " .. workedy)
- x, y, z = navigation.getPosition()
- workedy = y - starty
- if workedy < disY then
- drone.move(0,1,0)
- end
- if workedy > disY then
- drone.move(0,-1,0)
- end
- end
Add Comment
Please, Sign In to add comment