Sir_Popsilots

MineStairs

May 30th, 2022 (edited)
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.50 KB | None | 0 0
  1. local canstart = true
  2. print("please enter the current hight")
  3. io.write("Y cord: ")
  4. local ycord = io.read()
  5. ycord = tonumber(ycord)
  6. if ycord > 319  then
  7.     canstart = false
  8.     print("fuck you")
  9. end
  10.  
  11. print("please enter the desired depth")
  12. io.write("Y depth: ")
  13. local ydepth = io.read()
  14. ydepth = tonumber(ydepth)
  15. if ydepth < -64 then
  16.     canstart = false
  17.     print("fuck you")
  18. end    
  19.  
  20. print("Do you with for the turtle to come back?")
  21. io.write("Y/N: ")
  22. local ComeBack = io.read()
  23. ComeBack = string.lower(ComeBack)
  24. local original_y
  25. if string.match(ComeBack,"y") then
  26.     ComeBack = true
  27.     original_y = ycord
  28. else
  29.     ComeBack = false
  30. end
  31.  
  32. local notblocks = {"torch","sand","gravel"}
  33.  
  34. local function moveAndDigForwards()
  35.     while turtle.detect() do
  36.         turtle.dig()
  37.     end
  38.     turtle.forward()
  39. end
  40.  
  41. local function DigForward()
  42.     while turtle.detect() do
  43.         turtle.dig()
  44.     end
  45. end
  46.  
  47.  
  48.  
  49. local function findBlockToPlace()
  50.     for i=1,16 do
  51.         local slot = turtle.getItemDetail(i)
  52.         if slot ~= nil then
  53.             turtle.select(i)
  54.             local blockfound = true
  55.             for key,value in pairs(notblocks) do
  56.                 if string.find(slot.name,value) ~= nil then
  57.                     print("slot " , i , " is not a sutible")
  58.                     blockfound = false
  59.                 end
  60.             end
  61.             if blockfound then
  62.                 print("i found blocks to place")
  63.                 return i
  64.             end
  65.         end
  66.     end
  67.     print("i didnt find a block to place")
  68.     return false
  69. end
  70.  
  71. local BlockToPlaceSlot = findBlockToPlace()
  72.  
  73. local function digdown()
  74.     if not turtle.down() then
  75.         turtle.digDown()
  76.         turtle.down()
  77.     end
  78.     if (not turtle.detectDown()) and (BlockToPlaceSlot ~= false) then
  79.         turtle.select(BlockToPlaceSlot)
  80.         if not turtle.placeDown() then
  81.             BlockToPlaceSlot = findBlockToPlace()
  82.             if turtle.placeDown() then
  83.                 print("just placed a block underneeth me")
  84.             else
  85.                 os.exit()
  86.             end
  87.         end
  88.     end
  89.     ycord = ycord - 1
  90. end
  91.  
  92. local function findTorchSlot()
  93.     for i = 1,16 do
  94.         local slot = turtle.getItemDetail(i)
  95.         if (slot ~= nil) and (slot.name == "minecraft:torch") then
  96.             return i
  97.         end
  98.     end
  99.     return false
  100. end
  101.  
  102. local torchSlot = findTorchSlot()
  103.  
  104. local function placeTorch()
  105.     torchSlot = findTorchSlot()
  106.     if ycord % 10 == 0 and torchSlot ~= false then
  107.         turtle.select(torchSlot)
  108.         turtle.up()
  109.         turtle.placeUp()
  110.         turtle.down()
  111.     end
  112. end
  113.  
  114. local function MineLayer()
  115.     placeTorch()
  116.     digdown()
  117.     moveAndDigForwards()
  118.     moveAndDigForwards()
  119.     DigForward()
  120.     turtle.back()
  121. end
  122.  
  123. local function mainrun()
  124.     print("digging to depth ", ydepth)
  125.     while ycord ~= ydepth do
  126.         print("my depth is ", ycord)
  127.         MineLayer()
  128.     end
  129. end
  130. if canstart then
  131.     mainrun()
  132. else
  133.     turtle.select(BlockToPlaceSlot)
  134.     turtle.place()
  135. end
  136.  
  137. if ComeBack then
  138.     turtle.turnLeft()
  139.     turtle.turnLeft() --turtle turns around
  140.     while ycord ~= original_y do
  141.         turtle.forward()
  142.         if not turtle.detect() then
  143.             BlockToPlaceSlot = findBlockToPlace()
  144.             if BlockToPlaceSlot ~= false then
  145.                 turtle.select(BlockToPlaceSlot)
  146.                 turtle.place()
  147.             end
  148.         end
  149.         turtle.up()
  150.         ycord = ycord + 1
  151.     end
  152. end
Add Comment
Please, Sign In to add comment