Advertisement
Guest User

stripmine

a guest
Jul 19th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 KB | None | 0 0
  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.   turtle.select(3)
  16.   if enderchest then
  17.    turtle.select(2)
  18.    turtle.digDown()
  19.   else
  20.    chests = chests - 1
  21.   end
  22.  end
  23. end
  24.  
  25. function digforw()
  26.  if turtle.detect() then
  27.   turtle.dig()
  28.  end
  29.  turtle.forward()
  30.  dump()
  31.  turtle.digUp()
  32.  dump()
  33.  dist = dist + 1
  34. end
  35.  
  36. function home()
  37.  turtle.turnLeft()
  38.  turtle.turnLeft()
  39.  if turtle.detectUp() then
  40.   turtle.digUp()
  41.  end
  42.  turtle.up()
  43.  for i=1,dist,1 do
  44.   turtle.forward()
  45.  end
  46.  turtle.down()
  47.  if torch==0 then
  48.   print("Ran out of torches.")
  49.  elseif chests==0 then
  50.   print("Ran out of chests.")
  51.  else
  52.   print("Ran out of fuel.")
  53.  end
  54.  turtle.turnLeft()
  55.  turtle.turnLeft()
  56. end
  57.  
  58. function light()
  59.  turtle.turnLeft()
  60.  turtle.turnLeft()
  61.  turtle.select(1)
  62.  turtle.place()
  63.  turtle.turnLeft()
  64.  turtle.turnLeft()
  65.  torch = torch - 1
  66. end
  67.  
  68. local retdist = 0
  69. local fuel = turtle.getFuelLevel()
  70. function run()
  71.  while (torch>0) and (chests>0) and (fuel>retdist) do
  72.   for i=1,12,1 do
  73.    digforw()
  74.   end
  75.   light()
  76.   retdist = dist + 14
  77.   fuel = turtle.getFuelLevel()
  78.  end
  79.  home()
  80. end
  81.  
  82. run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement