Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Require component
- 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)
- -- Old Coords
- disX = -17
- disY = -100
- disZ = 0
- -- Open Port
- m.open(808)
- --Initial Values
- local port = 808
- local startx, starty, startz = navigation.getPosition()
- local function moveDirection(axis, worked, distance, start, port)
- -- IF WITHIN 1 BLOCK
- while (worked > distance + 1 or worked < distance - 1) do
- -- BROADCAST LOCATION
- m.broadcast(port, axis .. ": " .. worked)
- -- UPDATE LOCATION
- x, y, z = navigation.getPosition()
- if axis == "x" then
- worked = x - start
- end
- if axis == "y" then
- worked = y - start
- end
- if axis == "z" then
- worked = z - start
- end
- -- FORWARD
- if worked < distance then
- if axis == "x" then
- drone.move(1,0,0)
- end
- if axis == "y" then
- drone.move(0,1,0)
- end
- if axis == "z" then
- drone.move(0,0,1)
- end
- end
- -- REVERSE
- if worked > distance then
- if axis == "x" then
- drone.move(-1,0,0)
- end
- if axis == "y" then
- drone.move(0,-1,0)
- end
- if axis == "z" then
- drone.move(0,0,-1)
- end
- end
- end
- end
- moveDirection("x", 0, 10, startx, 808)
Add Comment
Please, Sign In to add comment