Advertisement
guamie

up

Apr 7th, 2020
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.02 KB | None | 0 0
  1. --FUNCTIONS
  2. --This is a set of all of the basic functions added to most programs
  3. --
  4. --MOVEMENT
  5. --
  6. --Turn turtle 180 Degrees in place ==========
  7. --
  8. function turnAround()
  9.         turtle.turnRight()
  10.         turtle.turnRight()
  11. end
  12. --
  13. --Ensure turtle goes up
  14. --
  15. function goUp()
  16.     while not turtle.up() do
  17.         upDig()
  18.     end
  19. end
  20. --    
  21. --Ensure turtle goes down
  22. --
  23. function goDown()
  24.     while not turtle.down() do
  25.         downDig()
  26.     end
  27. end
  28. --
  29. --Ensure turtle moves forward
  30. --
  31. function goForward()
  32.     while not turtle.forward() do
  33.         forwardDig()
  34.     end
  35. end
  36. --
  37. --Ensure Back (No)
  38. --We can't Ensure going back
  39. --Use 'shell.run("go back")' if needed.
  40. --
  41. --ACTION FUNCTIONS
  42. --
  43. --Dig forward
  44. --
  45. function forwardDig()
  46.     while turtle.detect() do
  47.         turtle.dig()
  48.     end
  49. end
  50. --
  51. --Dig up
  52. --
  53. function upDig()
  54.     while turtle.detectUp() do
  55.         turtle.digUp()
  56.     end
  57. end
  58. --
  59. --Dig Down
  60. --
  61. function downDig()
  62.     turtle.digDown()
  63. end
  64. --
  65. --Counter for inventer for the PLACE BLOCK DOWN function
  66. --More is needed here
  67. --Select next inventory slot if current is empty
  68. --
  69. --Counts stacks of items
  70. --
  71. function CounterBlock()
  72.     repeat
  73.     if turtle.getItemCount(slot) == 0 and slot ~=16 then
  74.         slot = slot + 1
  75.         turtle.select(slot)
  76.     elseif
  77.         turtle.getItemCount(slot) == 0 and slot ==16 then
  78.         term.clear()
  79.         print("I've run out of Material before finishing.  Add more to continue!")
  80.         slot = 1
  81.         turtle.select(slot)
  82.         repeat
  83.             sleep(1)
  84.         until turtle.getItemCount(slot) > 0
  85.         sleep(3)
  86.         print("Starting in 3 seconds")
  87. end
  88. until
  89. turtle.getItemCount(slot) > 0
  90. end
  91. --
  92. --Place Block Down
  93. --
  94. function placeDown()
  95.     turtle.select(slot)
  96.         turtle.placeDown()
  97.             CounterBlock()
  98. end
  99. --
  100. --Place Block Forward
  101. --
  102. function place()
  103.     turtle.select(slot)
  104.         turtle.place()
  105.             CounterBlock()
  106. end
  107. --
  108. --Place Block Up
  109. --
  110. function placeUp()
  111.     turtle.select(slot)
  112.         turtle.placeUp()
  113.             CounterBlock()
  114. end
  115. --
  116. ----------
  117. ----------
  118. ----------
  119. slot=1
  120. z=0
  121.  
  122. while not turtle.detectUp() do
  123. turtle.up()
  124. placeDown()
  125. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement