Advertisement
AKopyl

desander

Mar 22nd, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. local args = {...}
  2. local sand, area = 0, 0
  3.  
  4. local function fueled_forward()
  5.     while turtle.getFuelLevel() <= 0 do
  6.         turtle.select(1)
  7.         turtle.refuel(1)
  8.     end
  9.     while turtle.detect() do
  10.         turtle.dig()
  11.     end
  12.     turtle.forward()
  13. end
  14.  
  15. local function is_sand()
  16.     local _, data = turtle.inspectDown()
  17.     return data.name == 'minecraft:'..args[2]
  18. end
  19.  
  20. while true do
  21.     for x = 1, args[1], 1 do
  22.         for z = 1, args[1], 1 do
  23.             if is_sand() then
  24.                 turtle.digDown()
  25.                 sand = sand + 1
  26.             end
  27.             fueled_forward()
  28.             area = area + 1
  29.             print(math.floor(sand/area*100)..'% '..args[2]..' so far')
  30.         end
  31.         if x%2 == 0 then
  32.             turtle.turnLeft()
  33.             fueled_forward()
  34.             turtle.turnLeft()
  35.             fueled_forward()
  36.         else
  37.             turtle.turnRight()
  38.             fueled_forward()
  39.             turtle.turnRight()
  40.             fueled_forward()
  41.         end
  42.     end
  43.     print('This layer was'..math.floor(sand/area*100)..'% '..args[2])
  44.     if sand/area < .4 then
  45.         print('Not much '..args[2]..' left, stopping')
  46.         break
  47.     end
  48.     print('Moving on to next layer')
  49.     sand = 0
  50.     area = 0
  51.     turtle.digDown()
  52.     turtle.down()
  53.     if args[1]%2 == 0 then
  54.         turtle.turnLeft()
  55.     end
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement