Hashtagaming

mineFuelv2

Jul 31st, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. slot = 2
  2.  
  3. coal = 1
  4. chest = 2
  5. torch = 3
  6. stick = 4
  7. blocks = 5
  8.  
  9. turtle.select(2)
  10.  
  11. local args = {...}
  12.  
  13. local dist = tonumber(args[1])
  14.  
  15. local direct = tostring(args[2])
  16.  
  17. local function setSlot(s)
  18.   slot = s
  19.   turtle.select(s)
  20. end
  21.  
  22. local function checkFuel()
  23.   curSlot = slot
  24.   if turtle.getFuelLevel() < 10 then
  25.     setSlot(1)
  26.     turtle.refuel()
  27.     setSlot(curSlot)
  28.   end
  29. end
  30.  
  31. local function digForward()
  32.   checkFuel()
  33.   while not turtle.forward() do
  34.     turtle.dig()
  35.     turtle.digUp()
  36.   end
  37. end
  38.  
  39. local function turnAround(dir)
  40.   if dir == "left" then
  41.     turtle.turnLeft()
  42.     digForward()
  43.     turtle.turnLeft()
  44.   end
  45.   if dir == "right" then
  46.     turtle.turnRight()
  47.     digForward()
  48.     turtle.turnRight()
  49.   end
  50. end
  51.  
  52. while turtle.getItemCount(chest) > 0 do
  53.     for i=1,dist do
  54.       digForward()
  55.    if i%7==0 then
  56.      if direct == "left" then
  57.        turtle.turnRight()
  58.      end
  59.      if direct == "right" then
  60.        turtle.turnLeft()
  61.      end
  62.      turtle.dig()
  63.      turtle.select(torch)
  64.      turtle.place()
  65.     if direct == "left" then
  66.       turtle.turnLeft()
  67.     end
  68.     if direct == "right" then
  69.       turtle.turnRight()
  70.     end
  71.    end
  72.     end
  73.     turnAround(direct)
  74.     for i=1,dist do
  75.       digForward()
  76.     end
  77.     turtle.dig()
  78.     turtle.select(chest)
  79.     turtle.place()
  80.     for slot=4,16,1 do
  81.       turtle.select(slot)
  82.       while turtle.getItemCount(slot) > 0 do
  83.         turtle.drop()
  84.       end
  85.     end
  86.     if direct == "left" then
  87.    turtle.turnRight()
  88.  end
  89.  if direct == "right" then
  90.    turtle.turnLeft()
  91.  end
  92.     for i=1,3,1 do
  93.       digForward()
  94.     end
  95.     if direct == "left" then
  96.       turtle.turnRight()
  97.     end
  98.     if direct == "right" then
  99.       turtle.turnLeft()
  100.     end
  101. end
Advertisement
Add Comment
Please, Sign In to add comment