-- CONFIG START --
-- note: modem on a turtle is always on the right

-- CONFIG END --


local modem = peripheral.wrap("right")
if not modem.isOpen(59632) then modem.open(59632) end

local working = false
local running = true

function mtimer()
  while running do
    event,side,channel,reply,message = os.pullEvent("modem_message")
    working = message == "on"          
  end
end

function killbox()
  while running do
    if working then
      turtle.attack()
      sleep(1)
    else
      sleep(10)
    end
  end
end

parallel.waitForAll(killbox,mtimer)
