Advertisement
gur111

path_down.lua

Jun 13th, 2025
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. -- Function to dig forward safely
  2. local function digForward()
  3.     while not turtle.forward() do
  4.         turtle.dig()
  5.     end
  6. end
  7.  
  8. -- Function to move the turtle down safely
  9. local function moveDown()
  10.     while not turtle.down() do
  11.         turtle.digDown()
  12.     end
  13. end
  14.  
  15. -- Function to dig stairs downwards
  16. local function digStairsDown(count)
  17.     for i = 1, count do
  18.         turtle.dig()      -- Dig forward
  19.         digForward()      -- Move forward
  20.         moveDown()        -- Move down
  21.         turtle.digDown()  -- Dig down
  22.     end
  23. end
  24.  
  25. -- Function to parse command line arguments
  26. local function parseArgs(args)
  27.     local count = tonumber(args[1])
  28.     return count
  29. end
  30.  
  31. -- Get command line arguments
  32. local tArgs = {...}
  33. local stairsCount = parseArgs(tArgs)
  34.  
  35. -- Check if the number of stairs is provided
  36. if not stairsCount then
  37.     print("Usage: digStairsDown <number_of_stairs>")
  38.     return
  39. end
  40.  
  41. -- Start digging stairs down
  42. digStairsDown(stairsCount)
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement