Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. function isblock_f(id)
  2. local success, data = turtle.inspect()
  3. if success then
  4. if id == data.name then
  5. return true
  6. end
  7. end
  8. end
  9.  
  10. function isblock_l(id)
  11. turtle.turnLeft()
  12. local success, data = turtle.inspect()
  13. turtle.turnRight()
  14. if success then
  15. if id == data.name then
  16. return true
  17. end
  18. end
  19. end
  20.  
  21. function isblock_r(id)
  22. turtle.turnRight()
  23. local success, data = turtle.inspect()
  24. turtle.turnLeft()
  25. if success then
  26. if id == data.name then
  27. return true
  28. end
  29. end
  30. end
  31.  
  32. function isblock_u(id)
  33. local success, data = turtle.inspectUp()
  34. if success then
  35. if id == data.name then
  36. return true
  37. end
  38. end
  39. end
  40.  
  41. function isblock_d(id)
  42. local success, data = turtle.inspectDown()
  43. if success then
  44. if id == data.name then
  45. return true
  46. end
  47. end
  48. end
  49.  
  50. function isblock_b(id)
  51. turtle.turnLeft()
  52. turtle.turnLeft()
  53. local success, data = turtle.inspect()
  54. turtle.turnRight()
  55. turtle.turnRight()
  56. if success then
  57. if id == data.name then
  58. return true
  59. end
  60. end
  61. end
  62.  
  63. -- Stack Table
  64. -- Uses a table as stack, use <table>:push(value) and <table>:pop()
  65. -- Lua 5.1 compatible
  66.  
  67. -- GLOBAL
  68. Stack = {}
  69. orestack = Stack:Create()
  70.  
  71. -- Create a Table with stack functions
  72. function Stack:Create()
  73.  
  74. -- stack table
  75. local t = {}
  76. -- entry table
  77. t._et = {}
  78.  
  79. -- push a value on to the stack
  80. function t:push(...)
  81. if ... then
  82. local targs = {...}
  83. -- add values
  84. for _,v in ipairs(targs) do
  85. table.insert(self._et, v)
  86. end
  87. end
  88. end
  89.  
  90. -- pop a value from the stack
  91. function t:pop(num)
  92.  
  93. -- get num values from stack
  94. local num = num or 1
  95.  
  96. -- return table
  97. local entries = {}
  98.  
  99. -- get values into entries
  100. for i = 1, num do
  101. -- get last entry
  102. if #self._et ~= 0 then
  103. table.insert(entries, self._et[#self._et])
  104. -- remove last value
  105. table.remove(self._et)
  106. else
  107. break
  108. end
  109. end
  110. -- return unpacked entries
  111. return unpack(entries)
  112. end
  113.  
  114. -- get entries
  115. function t:getn()
  116. return #self._et
  117. end
  118.  
  119. -- list values
  120. function t:list()
  121. for i,v in pairs(self._et) do
  122. print(i, v)
  123. end
  124. end
  125. return t
  126. end
  127.  
  128. -- CHILLCODEā„¢
  129.  
  130. function minevein(id)
  131. if isblock_f(id) then
  132. print("f")
  133. turtle.dig()
  134. orestack.push("f")
  135. turtle.forward()
  136. return minevein(id)
  137. end
  138. if isblock_u(id) then
  139. print("u")
  140. turtle.digUp()
  141. orestack.push("u")
  142. turtle.up()
  143. return minevein(id)
  144. end
  145. if isblock_d(id) then
  146. print("d")
  147. turtle.digDown()
  148. orestack.push("d")
  149. turtle.down()
  150. return minevein(id)
  151. end
  152. turtle.turnLeft()
  153. if isblock_f(id) then
  154. print("l")
  155. turtle.dig()
  156. orestack.push("l")
  157. turtle.forward()
  158. return minevein(id)
  159. end
  160. turtle.turnLeft()
  161. if isblock_f(id) then
  162. print("b")
  163. turtle.dig()
  164. orestack.push("b")
  165. turtle.forward()
  166. return minevein(id)
  167. end
  168. turtle.turnLeft()
  169. if isblock_f(id) then
  170. print("r")
  171. turtle.dig()
  172. orestack.push("r")
  173. turtle.forward()
  174. return minevein(id)
  175. end
  176.  
  177. last_mov = orestack.pop(1)
  178. if last_mov != nil then
  179. if last_mov == "u" then
  180. turtle.down()
  181. return minevein(id)
  182. elseif last_mov == "d" then
  183. turtle.up()
  184. return minevein(id)
  185. else
  186. turtle.back()
  187. return minevein(id)
  188. end
  189. end
  190. end
  191.  
  192. turtle.refuel(5)
  193. print(turtle.getFuelLevel())
  194. minevein("minecraft:dirt")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement