Advertisement
DanFrmSpace

Untitled

Jun 3rd, 2023 (edited)
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. -- Making a Tutle that mines out a quarry
  2.  
  3. local tArgs = { ... }
  4. local x = tonumber(tArgs[1])
  5. local y = tonumber(tArgs[1])
  6. local z = tonumber(tArgs[2])
  7. local turnDir = 0
  8.  
  9. -- Check if there is a chest below the turtle
  10. function checkChest()
  11. if turtle.detectDown() then
  12. local success, data = turtle.inspectDown()
  13. if success then
  14. if data.name == "minecraft:chest" then
  15. return true
  16. end
  17. end
  18. end
  19. return false
  20. end
  21.  
  22.  
  23. function start()
  24. -- Check if there is a chest below the turtle
  25. if checkChest() then
  26. print("Chest found")
  27. turtle.turnRight()
  28. turtle.forward()
  29. turtle.dig()
  30. turtle.digDown()
  31. turtle.turnLeft()
  32. print("Starting to mine")
  33. else
  34. print("No chest found")
  35. end
  36. end
  37.  
  38. function mine()
  39. -- make an algortihmn that mines out a square using the x and y variables until the given z is reached
  40. -- then return to the starting position
  41. for i = 1, z do
  42. for j = 1, x do
  43. turtle.dig()
  44. turtle.forward()
  45. end
  46. if turnDir == 0 then
  47. turtle.turnRight()
  48. turtle.dig()
  49. turtle.forward()
  50. turtle.turnRight()
  51. turnDir = 1
  52. else
  53. turtle.turnLeft()
  54. turtle.dig()
  55. turtle.forward()
  56. turtle.turnLeft()
  57. turnDir = 0
  58. end
  59. end
  60. end
  61.  
  62. function main()
  63. start()
  64. mine()
  65. end
  66.  
  67. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement