rednet.open("right") connected = 0 oid = 0 x = 0 y = 0 z = 0 rotation = 0 function Forward() while turtle.detect() do turtle.dig() end turtle.forward() while turtle.detectUp() do turtle.digUp() end while turtle.detectDown() do turtle.digDown() end if rotation == 0 then z = z - 1 elseif rotation == 1 then x = x - 1 elseif rotation == 2 then z = z + 1 elseif rotation == 3 then x = x + 1 end end function Left() turtle.turnLeft() if rotation < 3 then rotati + 1 else rotati end end function Right() turtle.turnRight() if rotation > 0 then rotation = rotation - 1 else rotation = 3 end end function Backwards() turtle.back() if rotation == 0 then z = z + 1 elseif rotation == 1 then x = x + 1 elseif rotation == 2 then z = z - 1 elseif rotation == 3 then x = x - 1 end end function Up() end function Down() end function StartMine() distance = 0 while true do distance = distance + 1 if distance < 25 then Forward() elseif rotati 0 then Left() Forward() Left() distance = 0 elseif rotati 2 then Right() Forward() Right() distance = 0 end id, msg = rednet.receive(1) if id == oid and msg == "StopMine" then break end end end function Return() while true do if rotation > 0 then Right() else if z > 0 then Forward() elseif z < 0 then Left() Left() while z < 0 do Forward() end elseif x > 0 then while rotation ~= 1 do Left() end Forward() elseif x < 0 then while rotation ~= 3 do Left() end Forward() break end end end end while true do if c 0 then id, msg = rednet.receive() print("got msg: " .. msg) if msg == "Connect" then rednet.send(id, "kt") print("sent msg: kt") oid = id id, msg = rednet.receive() print("got msg: " .. msg) if id == oid then c end end elseif c 1 then id, msg = rednet.receive() print("got msg: " .. msg) if msg == "Mine" and id == oid then StartMine() elseif msg == "Return" and id == oid then Return() end end end