Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. function turtleBuildTower(height)
  2. local directions = {1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1, 3, 1, 1, 4, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1, 3, 1, 1, 4, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1, 3, 1, 1, 4, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1, 3, 1, 1, 4, 1, 1, 10}
  3.  
  4. local count = 0
  5. for _ in pairs(directions) do count = count + 1 end
  6.  
  7. for i = 1, height do
  8. for i = 1, count do
  9. if directions[i] == 1 then
  10. addForward()
  11. else
  12. turnTurtle(directions[i])
  13. end
  14. end
  15. end
  16. end
  17.  
  18. function addForward()
  19. local invi = checkInvi()
  20. while not turtle.forward() do
  21. turtle.dig()
  22. end
  23. while turtle.detectDown() do
  24. turtle.digDown()
  25. end
  26. if invi ~= false then
  27. turtle.select(invi)
  28. turtle.placeDown()
  29. else
  30. while not turtle.placeDown() do
  31. print(turtle.placeDown())
  32. end
  33. end
  34. end
  35.  
  36. function turnTurtle(turn)
  37. if turn == 2 then
  38. turtle.turnLeft()
  39. while not turtle.forward() do
  40. turtle.dig()
  41. end
  42. turtle.turnRight()
  43. elseif turn == 3 then
  44. while not turtle.forward() do
  45. turtle.dig()
  46. end
  47. turtle.turnLeft()
  48. elseif turn == 4 then
  49. turtle.turnRight()
  50. while not turtle.forward() do
  51. turtle.dig()
  52. end
  53. turtle.turnLeft()
  54. elseif turn == 10 then
  55. turtle.turnRight()
  56. while not turtle.forward() do
  57. turtle.dig()
  58. end
  59. turtle.turnLeft()
  60. while not turtle.up() do
  61. turtle.digUp()
  62. end
  63. end
  64. end
  65.  
  66. function checkInvi()
  67. for i = 1,16 do
  68. turtle.getItemCount(i)
  69. if turtle.getItemCount(i) > 0 then
  70. return i
  71. else
  72. return false
  73. end
  74. end
  75. end
  76.  
  77. turtleBuildTower(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement