CoderJohn

CCTurtleChunkMiner

Mar 17th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. local t_args = {...};
  2. local x,y,z = tonumber(t_args[1]),tonumber(t_args[2]),tonumber(t_args[3]);
  3. local cx, cy, cz = 1,1,1;
  4. down = function()
  5.   if(cy<=1)then return false; end
  6.   cy = cy-1;
  7.   if(turtle.detectDown())then turtle.digDown(); end
  8.   turtle.down();
  9.   return true;
  10. end
  11. up = function()
  12.   if(cy>=y)then return false; end
  13.   cy = cy+1;
  14.   if(turtle.detectUp())then turtle.digUp(); end
  15.   turtle.up();
  16.   return true;
  17. end
  18. local left = function()
  19.  -- if(cz<=1)then return false; end
  20.   cz = cz + 1;
  21.   turtle.turnLeft();
  22.   if(turtle.detect())then turtle.dig(); end
  23.   turtle.forward();
  24.   turtle.turnLeft();
  25.   return true;
  26. end
  27. local right = function()
  28.  -- if(cz>=z)then return false; end
  29.   cz = cz+1;
  30.   turtle.turnRight();
  31.   if(turtle.detect())then turtle.dig(); end
  32.   turtle.forward();
  33.   turtle.turnRight();
  34.   return true;
  35. end
  36. forward = function()
  37.     if(turtle.detect)then turtle.dig(); end
  38.     if(turtle.forward())then
  39.       cx = cx + 1;
  40.     else
  41.       print("Can't Move Forward");
  42.     end
  43.   return true;
  44. end
  45. while(cx<x or cz<z)do
  46.   if(cy<y)then
  47.     while(cy<y)do
  48.       up();
  49.     end
  50.   else
  51.     while(cy>1)do
  52.       down();
  53.     end
  54.   end
  55.   if(cx < x)then --not at end of row
  56.     forward();
  57.   elseif(cx==x)then
  58.     if(cz%2==1)then right(); else left(); end
  59.     cx = 0;
  60.   end
  61.   if(cx>=x and cz>=z)then
  62.     if(cy<y)then
  63.       while(cy<y)do
  64.         up();
  65.       end
  66.     else
  67.       while(cy>1)do
  68.         down();
  69.       end
  70.     end
  71.   end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment