Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. build(10)
  2.  
  3. function build(size)
  4. while true do
  5. placeLevel(size)
  6. turtle.up()
  7. turtle.up()
  8. turtle.up()
  9. turtle.turnRight()
  10. turtle.turnRight()
  11. end
  12. end
  13.  
  14. function placeLevel(size)
  15. local right = true
  16. for i = 0, size do
  17. line(size, endTurn(right))
  18. right = not right
  19. end
  20. end
  21.  
  22. function endTurn(right)
  23. if right then
  24. return function()
  25. turtle.turnRight()
  26. turtle.forward()
  27. turtle.turnRight()
  28. end
  29. else
  30. return function()
  31. turtle.turnLeft()
  32. turtle.forward()
  33. turtle.turnLeft()
  34. end
  35. end
  36. end
  37.  
  38. function line(size, last)
  39. for i = 0, size-1 do
  40. placeAnd(turtle.forward)
  41. end
  42. placeAnd(last)
  43. end
  44.  
  45. function placeAnd(action)
  46. findBuildMaterial(4)
  47. turtle.placeDown()
  48. action()
  49. end
  50.  
  51. function findBuildMaterial(id)
  52. local number = turtle.getSelectedSlot()
  53. local selected = turtle.getItemDetail(number)
  54. if selected.id == id and number > 0 then
  55. return
  56. end
  57. for i = id+1, 16 do
  58. selected = turtle.getItemDetail(i)
  59. local amount = turtle.getItemAmount(i)
  60. if selected.id == id then
  61. turtle.select(i)
  62. return
  63. end
  64. end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement