Advertisement
Fatherless

buildLine

Dec 9th, 2024 (edited)
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. --[[
  2. This program will clear out a line with length specified by the user and replace the blocks with the blocks in slot 1
  3.  
  4. The length is max 64
  5. --]]
  6.  
  7. --[[
  8. Functions
  9. --]]
  10.  
  11. local function tunnelFwd()
  12.     while not turtle.forward() do
  13.         turtle.dig()
  14.     end
  15. end
  16.  
  17. --[[
  18. Main
  19. --]]
  20.  
  21. print("How much in front of me would you like me to build? (max 64)")
  22. local length = tonumber(read())
  23.  
  24. if length > 64 then
  25.     print("I can only build 64 blocks")
  26. end
  27.  
  28. turtle.select(1)
  29. local count = turtle.getItemCount(1)
  30. if count < length then
  31.     print("Please provide me with enough blocks in slot 1 to build that.")
  32.     return
  33. end
  34.  
  35. local fuel = turtle.getFuelLevel()
  36. if fuel < length * 2 then
  37.     print("I only have " .. fuel .. " units of fuel! I need at least " .. length * 2 .. " units for that job")
  38.     return
  39. end
  40.  
  41. for i = 1, length do
  42.     tunnelFwd()
  43. end
  44.  
  45. for i = 1, length do
  46.     turtle.back()
  47.     turtle.place()
  48. end
  49.  
  50. print("Done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement