SHARE
TWEET

Untitled

a guest Jul 19th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local enderchest = false
  2. local torch = turtle.getItemCount(1)
  3. local chests = turtle.getItemCount(2)
  4. local dist = 0
  5.  
  6. function dump()
  7.  if turtle.getItemCount(16)>0 then
  8.   turtle.digDown()
  9.   turtle.select(2)
  10.   turtle.placeDown()
  11.   for slot = 3,16,1 do
  12.    turtle.select(slot)
  13.    turtle.dropDown()
  14.   end
  15.   if enderchest then
  16.    turtle.select(2)
  17.    turtle.digDown()
  18.   end
  19.  end
  20. end
  21.  
  22. function digforw()
  23.  if turtle.detect() then
  24.   turtle.dig()
  25.  end
  26.  turtle.forward()
  27.  dump()
  28.  turtle.digUp()
  29.  dump()
  30.  dist = dist + 1
  31. end
  32.  
  33. function home()
  34.  turtle.turnLeft()
  35.  turtle.turnLeft()
  36.  if turtle.detectUp() then
  37.   turtle.digUp()
  38.  end
  39.  turtle.up()
  40.  for i=1,dist,1 do
  41.   turtle.forward()
  42.  end
  43.  turtle.down()
  44.  if torch==0 then
  45.   print("Ran out of torches.")
  46.  elseif chests==0 then
  47.   print("Ran out of chests.")
  48.  else
  49.   print("Ran out of fuel.")
  50.  end
  51.  turtle.turnLeft()
  52.  turtle.turnLeft()
  53. end
  54.  
  55. function light()
  56.  turtle.turnLeft()
  57.  turtle.turnLeft()
  58.  turtle.select(1)
  59.  turtle.place()
  60.  turtle.turnLeft()
  61.  turtle.turnLeft()
  62.  torch = torch - 1
  63. end
  64.  
  65. local retdist = 0
  66. local fuel = turtle.getFuelLevel()
  67. function run()
  68.  while (torch>0) and (chests>0) and (fuel>retdist) do
  69.   for i=1,12,1 do
  70.    digforw()
  71.   end
  72.   light()
  73.   retdist = dist + 14
  74.   fuel = turtle.getFuelLevel()
  75.  end
  76.  home()
  77. end
  78.  
  79. run()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top