Advertisement
dexman545

Miner

May 16th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. tArgs = {...}
  2.  
  3. if tArgs[1] == nil then
  4. term.clear()
  5. term.setCursorPos(1,1)
  6. print("Error: Missing Arguments")
  7. term.setCursorPos(1,2)
  8. print("radius, current Y, min Y")
  9. end
  10.  
  11. r = tArgs[1]
  12. currY = tArgs[2]
  13. minY = tArgs[3]
  14.  
  15. function fWrite(f)
  16. local file = fs.open(f, "w")
  17. dbs = textutils.serialize(text)
  18. file.write(dbs)
  19. file.close()
  20. end
  21.  
  22. function fRead(f)
  23. local file = fs.open(f, "r")
  24. text = textutils.unserialize(file.readAll())
  25. return text
  26. end
  27.  
  28. function getLoc()
  29. x, y, z = gps.locate(2, true)
  30. return x, y, z
  31. end
  32.  
  33. function move()
  34. repeat turtle.forward()
  35. sleep(1)
  36. turtle.dig()
  37. until turtle.forward() == true
  38. dH = dH + 1
  39. local text = dH
  40. fWrite("lDistance")
  41. end
  42.  
  43. function forward(r)
  44. for i = 1, r do
  45. if turtle.getFuelLevel() < minFuel() + 1 then
  46. turtle.select(16)
  47. if turtle.count == 1 then
  48. return()
  49. else
  50. turtle.refuel()
  51. move()
  52. end
  53. else move()
  54. end
  55. end
  56. end
  57.  
  58. function compare()
  59. for local i = 1, #cSlots do
  60. turtle.select(cSlots[i])
  61. if turtle.compareUp() == false then
  62. turtle.digUp()
  63. end
  64. if turtle.compareDown() == false then
  65. turtle.digDown()
  66. end
  67. end
  68. end
  69.  
  70. function load()
  71. for local i = 1, 15 do
  72. turtle.select(i)
  73. local x = turtle.count()
  74. if x > 0 then
  75. cSlots[i] = i
  76. end
  77. end
  78. end
  79.  
  80. function minFuel()
  81. fRead("lDistance")
  82. minFuel = text
  83. return minFuel
  84. end
  85.  
  86. function layer()
  87. for local i = 1, r do
  88. for local i = 1, r do
  89. for local i = 1, r do
  90. forward(1)
  91. end
  92. turtle.turnLeft()
  93. forward(1)
  94. turtle.turnLeft()
  95. end
  96. end
  97. end
  98.  
  99. function mineLayer()
  100. if minY = nil then
  101. toY = 6
  102. else toY = minY
  103. end
  104. for local i = currY - toY do
  105. turtle.digDown()
  106. turtle.down()
  107. local text = i
  108. fWrite(mineY)
  109. end
  110. layer()
  111.  
  112. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement