diff --git a/drone.lua b/drone.lua index 78b5b66..a287c95 100644 --- a/drone.lua +++ b/drone.lua @@ -2,14 +2,21 @@ local drone = component.proxy(component.list("drone")()) local function fly(dx, dy, dz) drone.move(dx, dy, dz) + drone.setStatusText(math.floor(dx) .. "," .. math.floor(dy) .. "," .. math.floor(dz)) - while drone.getOffset() > 1 do + while drone.getOffset() > 0.5 do computer.pullSignal(0.1) end end while true do - fly(0,2,0) - fly(10,0,0) - fly(-10,0,0) - fly(0,-2,0) + local signal = table.pack(computer.pullSignal()) + if signal[1] == "motion" then + if signal[6] == "Zombie" then + fly(signal[3], signal[4]+2, signal[5]) + if drone.getOffset() < 1 then + drone.setStatusText('' .. drone.getOffset()) + drone.swing(3) -- forward + end + end + end end