Advertisement
9551

Untitled

Jan 25th, 2024
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1.  
  2. --The program's purpose is to ask to the user how many block does he wants the turtle to mine in height, length and width
  3. --everything works fine until the turtle tries to increase is width,
  4. --instead of turning left or right (it depends if the height is odd or not) then rotate on 180° and finally return to its starting height
  5. --it doesn't.
  6. local fLevel = turtle.getFuelLevel()
  7. term.clear()
  8. term.setCursorPos(1, 1)
  9. --Don't mind this, I used this from the wiki
  10. local ok, err = turtle.refuel(), "Not refuelled\n"
  11. if ok then
  12. local new_level = turtle.getFuelLevel()
  13. print(("Refuelled %d, current level is %d\n"):format(new_level - fLevel, new_level))
  14. else
  15. printError(err)
  16. end
  17. --Now you can mind my following code
  18. print("Height to mine : ")
  19. local height = read()
  20. print("\nLength to mine : ");
  21. local length = read()
  22. print("\nWidth to mine : ")
  23. local width = read()
  24. for i = 1, width do
  25. for j = 1, height do
  26. for k = 1, length do
  27. if turtle.detect() then
  28. turtle.dig()
  29. end
  30. turtle.forward()
  31. end
  32. if turtle.detectUp() then
  33. turtle.digUp()
  34. end
  35. turtle.up()
  36. turtle.turnRight()
  37. turtle.turnRight()
  38. end
  39. --les problèmes commencent juste ici / problems start here
  40. if height % 2 ~= 0 then
  41. turtle.turnLeft()
  42. if turtle.detect() then
  43. turtle.dig()
  44. end
  45. turtle.forward()
  46. turtle.turnLeft()
  47.  
  48. else
  49.  
  50. turtle.turnRight()
  51. if turtle.detect() then
  52. turtle.dig()
  53. end
  54. turtle.forward()
  55. turtle.turnRight()
  56. end
  57. for l = 1, height do --reset turtle's height
  58. if turtle.detectDown() then
  59. turtle.digDown()
  60. end
  61. turtle.down()
  62. end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement