Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. function Fuel()
  2. if turtle.getFuelLevel() == 0 then
  3. turtle.refuel(1)
  4. end
  5. end
  6.  
  7. function Forward()
  8. Fuel()
  9. for i=1,5 do
  10. if turtle.detect() then
  11. turtle.dig()
  12. end
  13. end
  14. return turtle.forward()
  15. end
  16.  
  17. function FForward()
  18. while Forward() == false do
  19. end
  20. end
  21.  
  22. function FBack()
  23. Fuel()
  24. if turtle.back() == false then
  25. turtle.turnLeft()
  26. turtle.turnLeft()
  27. FForward()
  28. turtle.turnLeft()
  29. turtle.turnLeft()
  30. end
  31. end
  32.  
  33. function Up()
  34. Fuel()
  35. for i=1,5 do
  36. if turtle.detectUp() then
  37. turtle.digUp()
  38. end
  39. end
  40. return turtle.up()
  41. end
  42.  
  43. function FUp()
  44. while Up() == false do
  45. end
  46. end
  47.  
  48.  
  49. function Down()
  50. Fuel()
  51. for i=1,5 do
  52. if turtle.detectDown() then
  53. turtle.digDown()
  54. end
  55. end
  56. return turtle.down()
  57. end
  58.  
  59. function FDown()
  60. while Down() == false do
  61. end
  62. end
  63.  
  64. function InfUp()
  65. local x = 0
  66. while (turtle.detectUp()) and (Up()) do
  67. x = x+1
  68. end
  69. for i=1,x do
  70. FDown()
  71. end
  72. end
  73.  
  74. function InfDown()
  75. local x = 0
  76. while Down() do
  77. x = x+1
  78. end
  79. for i=1,x do
  80. FUp()
  81. end
  82. end
  83.  
  84. function CleanInventory()
  85. for i=2,16 do
  86. turtle.select(i)
  87. turtle.drop(64)
  88. end
  89. turtle.select(1)
  90. end
  91.  
  92. function Refuel()
  93. turtle.suck(64)
  94. for i=2,16 do
  95. if turtle.getItemCount(i) > 0 then
  96. data = turtle.getItemDetail(i)
  97. if (data.name == 'minecraft:coal') then
  98. turtle.select(i)
  99. turtle.drop(64)
  100. turtle.select(1)
  101. end
  102. end
  103. end
  104. end
  105.  
  106. function ThrowAway()
  107. for i=2,16 do
  108. if turtle.getItemCount(i) > 0 then
  109. data = turtle.getItemDetail(i)
  110. if isBlackListed(data) then
  111. turtle.select(i)
  112. turtle.dropDown(64)
  113. end
  114. end
  115. end
  116. turtle.select(1)
  117. end
  118.  
  119.  
  120. function isBlackListed(data)
  121. if data.name == 'minecraft:stone' then
  122. return true
  123. end
  124. if data.name == 'minecraft:cobblestone' then
  125. return true
  126. end
  127. if data.name == 'minecraft:dirt' then
  128. return true
  129. end
  130. if data.name == 'minecraft:grass' then
  131. return true
  132. end
  133. if data.name == 'minecraft:sand' then
  134. return true
  135. end
  136. if data.name == 'minecraft:gravel' then
  137. return true
  138. end
  139. if data.name == 'minecraft:bedrock' then
  140. return true
  141. end
  142. if data.name == 'minecraft:water' then
  143. return true
  144. end
  145. if data.name == 'minecraft:flowing_water' then
  146. return true
  147. end
  148. if data.name == 'minecraft:lava' then
  149. return true
  150. end
  151. if data.name == 'minecraft:flowing_lava' then
  152. return true
  153. end
  154. if data.name == 'chisel:limestone2' then
  155. return true
  156. end
  157. if data.name == 'chisel:marble2' then
  158. return true
  159. end
  160. if data.name == 'buildcraftenergy:fluid_block_oil_heat_0' then
  161. return true
  162. end
  163.  
  164. return false
  165. end
  166.  
  167. MAXDEPTH = 50
  168.  
  169. function filon(depth)
  170. if depth >= MAXDEPTH then
  171. return true
  172. end
  173. local success,data = turtle.inspectUp()
  174. if success and (isBlackListed(data) == false) then
  175. FUp()
  176. filon(depth+1)
  177. FDown()
  178. end
  179. success,data = turtle.inspectDown()
  180. if success and (isBlackListed(data) == false) then
  181. FDown()
  182. filon(depth+1)
  183. FUp()
  184. end
  185. for i=1,4 do
  186. success,data = turtle.inspect()
  187. if success and (isBlackListed(data) == false) then
  188. FForward()
  189. filon(depth+1)
  190. FBack()
  191. end
  192. turtle.turnRight()
  193. end
  194. end
  195.  
  196. function goBack(X,Y,Z)
  197. for i=1,Z do
  198. FUp()
  199. end
  200. for i=1,Y do
  201. FBack()
  202. end
  203. turtle.turnLeft()
  204. for i=1,X do
  205. FBack()
  206. end
  207. end
  208.  
  209. function goForward(X,Y,Z)
  210. for i=1,X do
  211. FForward()
  212. end
  213. turtle.turnRight()
  214. for i=1,Y do
  215. FForward()
  216. end
  217. for i=1,Z do
  218. FDown()
  219. end
  220. end
  221.  
  222. function verFilon()
  223. local z = 0
  224. while Down() do
  225. z = z+1
  226. ThrowAway()
  227. filon(0)
  228.  
  229. end
  230. for i=1,z do
  231. FUp()
  232. end
  233. end
  234.  
  235.  
  236. wid,iX,iY = ...
  237.  
  238. wid = tonumber(wid)
  239. iX = tonumber(iX)
  240. iY = tonumber(iY)
  241.  
  242. while (iX < wid) or (iY < wid) do
  243. x = 4*iX+2
  244. y = 4*iY+2
  245. goForward(x,y,0)
  246. Z=0
  247. while Down() do
  248. Z = Z+1
  249. if (Z%4 == 0) then
  250. ThrowAway()
  251. end
  252. filon(0)
  253. if turtle.getItemCount(16) > 0 then
  254. goBack(x,y,Z)
  255. turtle.turnLeft()
  256. Refuel()
  257. turtle.turnLeft()
  258. CleanInventory()
  259. turtle.turnLeft()
  260. turtle.turnLeft()
  261. goForward(x,y,Z)
  262. end
  263. end
  264. goBack(x,y,Z)
  265. turtle.turnLeft()
  266. Refuel()
  267. turtle.turnLeft()
  268. CleanInventory()
  269. turtle.turnLeft()
  270. turtle.turnLeft()
  271.  
  272.  
  273. iY = iY +1
  274. if iY >= wid then
  275. iX = iX +1
  276. iY = 0
  277. end
  278. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement