Advertisement
SwellzD

grassStacker.lua

Jul 30th, 2022 (edited)
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.72 KB | None | 0 0
  1. print("x:")
  2. local x = read()
  3. print("y:")
  4. local y = read()
  5.  
  6. local ix = 0
  7. local iy = 0
  8. local ii = 0
  9.  
  10. local i = true
  11. while i do
  12.     print("Please, enter the direction where the turtle will go ( r / l )")
  13.     local direction = read()
  14.     if direction == "r" then
  15.         ii = 0
  16.         print("Accepted! Direction is Right")
  17.         i = false
  18.     elseif direction == "l" then
  19.         ii = 1
  20.         print("Accepted! Direction is Left")
  21.         i = false
  22.     else
  23.         print("Incorrect value")
  24.     end
  25. end
  26.  
  27. local count = 0
  28. local slot = 1
  29. local block, data = turtle.inspectDown()
  30. print(block, data.name)
  31.  
  32. for ix = 0, x - 1 do
  33.     block, data = turtle.inspectDown()
  34.    
  35.     if count == 63 then
  36.         slot = slot + 1
  37.         count = 0
  38.     end
  39.    
  40.     if slot <= 16 then
  41.         turtle.select(slot)
  42.     else
  43.         print("Out blocks!!!")
  44.         os.pullEventRaw()
  45.     end
  46.    
  47.     if block == true then
  48.         if (data.name ~= "minecraft:grass_block") and (data.name ~= "minecraft:dirt") then
  49.             turtle.dig()
  50.             turtle.digDown()
  51.             turtle.placeDown()
  52.             count = count + 1
  53.             turtle.forward()
  54.         else
  55.             turtle.dig()
  56.             turtle.forward()
  57.         end
  58.     else
  59.         turtle.dig()
  60.         turtle.digDown()
  61.         turtle.placeDown()
  62.         count = count + 1
  63.         turtle.forward()
  64.     end
  65. end
  66. for iy = 0, y - 1 do
  67.     turtle.refuel()
  68.     turtle.getFuelLevel()
  69.     if ii % 2 == 0 then
  70.         turtle.turnRight()
  71.         turtle.dig()
  72.         turtle.digDown()
  73.         turtle.placeDown()
  74.         count = count + 1
  75.         turtle.forward()
  76.         turtle.turnRight()
  77.     else
  78.         turtle.turnLeft()
  79.         turtle.dig()
  80.         turtle.digDown()
  81.         turtle.placeDown()
  82.         count = count + 1
  83.         turtle.forward()
  84.         turtle.turnLeft()
  85.     end
  86.     ii = ii + 1
  87.     for ix = 0, x - 1 do
  88.         block, data = turtle.inspectDown()
  89.    
  90.         if count == 63 then
  91.             slot = slot + 1
  92.            count = 0
  93.         end
  94.    
  95.         if slot <= 16 then
  96.             turtle.select(slot)
  97.         else
  98.             print("Out blocks!!!")
  99.             os.pullEventRaw()
  100.         end
  101.        
  102.         if block == true then
  103.             if (data.name ~= "minecraft:grass_block") and (data.name ~= "minecraft:dirt") then
  104.                 turtle.dig()
  105.                 turtle.digDown()
  106.                 turtle.placeDown()
  107.                 count = count + 1
  108.                 turtle.forward()
  109.             else
  110.                 turtle.dig()
  111.                 turtle.forward()
  112.             end
  113.         else
  114.             turtle.dig()
  115.             turtle.digDown()
  116.             turtle.placeDown()
  117.             count = count + 1
  118.             turtle.forward()
  119.         end
  120.     end
  121.     ix = 0
  122. end
  123. turtle.digDown()
  124. turtle.placeDown()    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement