SoundChaos

Cylinder

Jul 30th, 2014
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. -- Inventory Slot Variable
  2. local p = 2
  3. -- Repeat variable for up one level + full circle
  4. local o = 1
  5. -- Repeat variable for one quarter of a circle
  6. local i = 1
  7.  
  8.  
  9. -- consumes initial fuel, then selects slot 2, and turns on wifi
  10. turtle.refuel(1)
  11. turtle.select(2)
  12.  
  13. -- Function to get the number of items in a given slot
  14. bcount = function()
  15. return turtle.getItemCount(p)
  16. end
  17.  
  18. -- Function to get the fuel level of the robot
  19. fcount = function()
  20. return turtle.getFuelLevel()
  21. end
  22.  
  23. --[[ All in one check and fix function - it checks for empty item slots and moves
  24. slot over when needed, and it checks for fuel level, and refules when needed
  25. --]]
  26. check = function()
  27. if bcount() < 1 then
  28. p = p + 1
  29. turtle.select(p)
  30. end
  31. print ("My current fuel level is " .. fcount())
  32. if fcount() < 1 then
  33. print ("Attempting to eat my fuel...")
  34. if turtle.getItemCount(1) < 1 then
  35. print ("I am out of fuel...")
  36. o = 0
  37. end
  38. turtle.select(1)
  39. turtle.refuel(1)
  40. turtle.select(p)
  41. end
  42. end
  43.  
  44. --[[ Basic right corner, it really just moves the turtle like so:
  45. -->-->
  46. |
  47. -->-->
  48. --]]
  49. rCorner = function()
  50. turtle.turnRight()
  51. turtle.forward()
  52. turtle.turnLeft()
  53. end
  54.  
  55. --[[ Basic left corner, it really just moves the turtle like so:
  56. -->-->
  57. |
  58. -->-->
  59. --]]
  60. lCorner = function()
  61. turtle.turnLeft()
  62. turtle.forward()
  63. turtle.turnRight()
  64. end
  65.  
  66. -- Function for Place block down, and move forward, very common movement.
  67. pfmove = function()
  68. turtle.placeDown()
  69. turtle.forward()
  70. check()
  71. end
  72.  
  73. --[[ Main code loop for creating a tower, it will continue until it runs out of
  74. blocks or runs out of fuel (if it does run out of blocks, it will still move up
  75. until it runs out of fuel)
  76. --]]
  77. repeat
  78. turtle.up()
  79. print("Attempting to build next level")
  80. repeat
  81. for t=1,5 do
  82. pfmove()
  83. end
  84. rCorner()
  85. for t=1,2 do
  86. pfmove()
  87. end
  88. rCorner()
  89. pfmove()
  90. turtle.turnRight()
  91. for t=1, 2 do
  92. turtle.forward()
  93. turtle.placeDown()
  94. check()
  95. end
  96. lCorner()
  97. turtle.forward()
  98. i = i + 1
  99. until i == 5
  100. i = 1
  101. until o == 0
Advertisement
Add Comment
Please, Sign In to add comment