Advertisement
smigger22

Turtle

Jun 15th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. local moves = 0
  2. tArgs = { ... }
  3. function move( dig )
  4. if dig == true then
  5. turtle.dig()
  6. while not turtle.forward() do
  7. turtle.dig()
  8. end
  9. end
  10. end
  11.  
  12. function upAndDown()
  13. turtle.digUp()
  14. turtle.digDown()
  15. end
  16.  
  17. function row()
  18. move( true )
  19. upAndDown()
  20. end
  21.  
  22. function checkForFuel()
  23. for i = 1, 16 do
  24. result = turtle.getItemDetail()
  25. if result then
  26. if result.name == "minecraft:coal" then
  27. turtle.select( i )
  28. if result.count / 4 == math.floor( result.count / 4 ) then
  29. turtle.refuel( result.count / 4)
  30. else
  31. turtle.refuel( math.floor( result.count / 4 ) )
  32. end
  33. end
  34. end
  35. end
  36. end
  37.  
  38. function work( t )
  39. for i = 1, t[ 1 ] do
  40. if turtle.getFuelLevel() < 100 then
  41. checkForFuel()
  42. end
  43. row()
  44. turtle.turnLeft()
  45. row()
  46. while not turtle.back() do
  47. turtle.dig()
  48. end
  49. turtle.turnRight()
  50. turtle.turnRight()
  51. row()
  52. while not turtle.back() do
  53. turtle.dig()
  54. end
  55. turtle.turnLeft()
  56. moves = moves + 1
  57. end
  58. end
  59.  
  60. if #tArgs ~= 1 then
  61. print( "Usage: " .. shell.getRunningProgram() .. " <length>" )
  62. else
  63. work( tArgs )
  64. for i = 1, moves do
  65. turtle.back()
  66. end
  67. end
  68. =
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement