Advertisement
Hashtagaming

mineFuel

Jul 28th, 2013
1,677
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. --DISCLAIMER!!!!
  2. --THIS IS BETA CODE! IF THERE IS A GLITCH ON THE CODE, PLEASE MESSAGE ME AT YOUTUBE.COM/HASHTAGAMING
  3. --When running the code running it like so "mineFuel <length of tunnel "any number"> <direction "left" or "right">
  4.  
  5. slot = 2
  6.  
  7. coal = 1
  8. chest = 2
  9. blocks = 3
  10.  
  11. turtle.select(2)
  12.  
  13. local args = {...}
  14.  
  15. local dist = tonumber(args[1])
  16.  
  17. local direct = tostring(args[2])
  18.  
  19. local function setSlot(s)
  20.   slot = s
  21.   turtle.select(s)
  22. end
  23.  
  24. local function checkFuel()
  25.   curSlot = slot
  26.   if turtle.getFuelLevel() < 10 then
  27.     setSlot(1)
  28.     turtle.refuel()
  29.     setSlot(curSlot)
  30.   end
  31. end
  32.  
  33. local function digForward()
  34.   checkFuel()
  35.   while not turtle.forward() do
  36.     turtle.dig()
  37.     turtle.digUp()
  38.   end
  39. end
  40.  
  41. local function turnAround(dir)
  42.   if dir == "left" then
  43.     turtle.turnLeft()
  44.     digForward()
  45.     turtle.turnLeft()
  46.   end
  47.   if dir == "right" then
  48.     turtle.turnRight()
  49.     digForward()
  50.     turtle.turnRight()
  51.   end
  52. end
  53.  
  54. while turtle.getItemCount(chest) > 0 do
  55.     for i=1,dist do
  56.       digForward()
  57.     end
  58.     turnAround(direct)
  59.     for i=1,dist do
  60.       digForward()
  61.     end
  62.     turtle.dig()
  63.     turtle.select(chest)
  64.     turtle.place()
  65.     for slot=3,16,1 do
  66.       turtle.select(slot)
  67.       while turtle.getItemCount(slot) > 0 do
  68.         turtle.drop()
  69.       end
  70.     end
  71.     if direct == "left" then
  72.    turtle.turnRight()
  73.  end
  74.  if direct == "right" then
  75.    turtle.turnLeft()
  76.  end
  77.     for i=1,3,1 do
  78.       digForward()
  79.     end
  80.     if direct == "left" then
  81.       turtle.turnRight()
  82.     end
  83.     if direct == "right" then
  84.       turtle.turnLeft()
  85.     end
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement