Advertisement
pson

flatten.lua

Jun 16th, 2020
1,176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. function fixChunk()
  2.     local i = 2
  3.     turtle.select(2)
  4.     if turtle.detectDown() and not turtle.compareDown() then
  5.         turtle.digDown()
  6.     end
  7.  
  8.     if not turtle.detectDown() then
  9.         while turtle.getItemCount(i) < 2 do
  10.             i = i+1
  11.         end
  12.         turtle.select(i)
  13.         turtle.placeDown()
  14.     end
  15. end
  16.  
  17. function forward()
  18.     while turtle.detect() do
  19.         turtle.dig()
  20.         sleep(0.5)
  21.     end
  22.     flag = turtle.forward()
  23.     while not flag do
  24.         turtle.attack()
  25.         sleep(0.5)
  26.         flag = turtle.forward()
  27.     end
  28. end
  29.  
  30. function backAndForth()
  31.     local i
  32.  
  33.  
  34.     turtle.select(1)
  35.     while turtle.getFuelLevel() < 40 do
  36.         turtle.refuel(1)
  37.     end
  38.  
  39.     for i=0,14,1 do
  40.         fixChunk()
  41.         forward()
  42.     end
  43.     fixChunk()
  44.     turtle.turnLeft()
  45.     forward()
  46.     turtle.turnLeft()
  47.     for i=0,14,1 do
  48.         fixChunk()
  49.         forward()
  50.     end
  51.     fixChunk()
  52. end
  53.  
  54. function lawn()
  55.     local i
  56.  
  57.     for i = 0,6,1 do
  58.         backAndForth()
  59.         turtle.turnRight()
  60.         forward()
  61.         turtle.turnRight()
  62.     end
  63.     backAndForth()
  64.     turtle.turnLeft()
  65.     for i=1,15,1 do
  66.         forward()
  67.     end
  68. end
  69.  
  70. lawn()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement