Advertisement
Guest User

janMine

a guest
Dec 3rd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.09 KB | None | 0 0
  1. xMoved = 0
  2. zMoved = 0
  3. dir = 0
  4. turn = false
  5.  
  6. function mob()
  7.   while turtle.attack() do
  8.     turtle.sleep(0.2)
  9.   end
  10. end
  11.  
  12. function w()
  13.   while turtle.detect() do
  14.     turtle.dig()
  15.   end
  16.  
  17.   while not turtle.detect() and not turtle.forward() do
  18.     turtle.attack()
  19.   end
  20.   turtle.digUp()
  21.   if dir == 0 then
  22.     xMoved = xMoved + 1
  23.   elseif dir == 1 then
  24.     zMoved = zMoved + 1
  25.   elseif dir == 2 then
  26.     xMoved = xMoved - 1
  27.   else zMoved = zMoved - 1
  28.   end
  29. end
  30.  
  31. function a()
  32.   turtle.turnLeft()
  33.   if dir == 0 then
  34.     dir = 3
  35.   elseif dir == 1 then
  36.     dir = 0
  37.   elseif dir == 2 then
  38.     dir = 1
  39.   else dir = 2
  40.   end
  41. end
  42.  
  43. function d()
  44.   turtle.turnRight()
  45.   if dir == 0 then
  46.     dir = 1
  47.   elseif dir == 1 then
  48.     dir = 2
  49.   elseif dir == 2 then
  50.     dir = 3
  51.   else dir = 0
  52.   end
  53. end
  54.  
  55. function home()
  56.   if (zMoved < 0) then
  57.   turn = true
  58.     while not (dir == 1) do
  59.       d()
  60.     end
  61.     while (zMoved < 0) do
  62.       w()
  63.     end
  64.   elseif (zMoved > 0) then
  65.   turn = true
  66.     while not (dir == 3) do
  67.       turtle.up()
  68.       a()
  69.     end
  70.     while (zMoved > 0) do
  71.       w()
  72.     end
  73.   end
  74.   if (xMoved < 0) then
  75.   turn = true
  76.     while not (dir == 0) do
  77.       a()
  78.     end
  79.     while (xMoved < 0) do
  80.       w()
  81.     end
  82.   elseif (xMoved > 0) then
  83.   turn = true
  84.     while not (dir == 2) do
  85.       d()
  86.     end
  87.     while (xMoved > 0) do
  88.       w()
  89.     end
  90.   end
  91.   if turn == true then
  92.     turtle.turnLeft()
  93.     turtle.turnLeft()
  94.   end
  95. end
  96.    
  97. function pos()
  98.   w()
  99.   w()
  100.   w()
  101. end
  102.  
  103. function strip()
  104.   if turtle.detect() == false then
  105.     a()
  106.     w()
  107.     w()
  108.     w()
  109.     d()
  110.     strip()
  111.   end
  112. end
  113.  
  114. function mine()
  115.   w()
  116.   w()
  117.   w()
  118.   d()
  119.   w()
  120.   w()
  121.   d()
  122.   d()
  123.   w()
  124.   w()
  125.   d()
  126.   if turtle.getFuelLevel() == 0 then
  127.     getFuel()
  128.     turtle.select(16)
  129.     turtle.refuel()
  130.   end
  131. end
  132.  
  133. function session()
  134.   i = 0
  135.   while i < 10 do
  136.   i = i+1
  137.     mine()
  138.     turtle.select(16)
  139.     turtle.refuel(4)
  140.   end
  141.   getFuel()
  142.   dropItems()
  143. end
  144.  
  145. function dropItems()
  146.   while turtle.detectUp() do
  147.     turtle.digUp()
  148.   end
  149.   turtle.select(2)
  150.   turtle.placeUp()
  151.   turtle.select(3)
  152.   turtle.dropUp()
  153.   turtle.select(4)
  154.   turtle.dropUp()
  155.   turtle.select(5)
  156.   turtle.dropUp()
  157.   turtle.select(6)
  158.   turtle.dropUp()
  159.   turtle.select(7)
  160.   turtle.dropUp()
  161.   turtle.select(8)
  162.   turtle.dropUp()
  163.   turtle.select(9)
  164.   turtle.dropUp()
  165.   turtle.select(10)
  166.   turtle.dropUp()
  167.   turtle.select(11)
  168.   turtle.dropUp()
  169.   turtle.select(12)
  170.   turtle.dropUp()
  171.   turtle.select(13)
  172.   turtle.dropUp()
  173.   turtle.select(14)
  174.   turtle.dropUp()
  175.   turtle.select(15)
  176.   turtle.dropUp()
  177.   turtle.select(2)
  178.   turtle.digUp()
  179. end
  180.  
  181. function getFuel()
  182.   while turtle.detectUp() do
  183.     turtle.digUp()
  184.   end
  185.  
  186.  turtle.select(1)
  187.  turtle.placeUp()
  188.  turtle.select(16)
  189.  turtle.suckUp(turtle.getItemSpace(16))
  190.  turtle.digUp()
  191.  if turtle.getItemSpace(16) > 32 then
  192.    home()
  193.    error()
  194.  end
  195. end
  196.  
  197. function plan1()
  198.   getFuel()
  199.   pos()
  200.   strip()
  201.   session()
  202.   session()
  203.   home()
  204. end
  205.  
  206. plan1()
  207. plan1()
  208. plan1()
  209. --pos()
  210. --strip()
  211. --session()
  212. --home()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement