Advertisement
DreamPhreak

floordig1

Sep 22nd, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.15 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1, 1)
  3. shell.run("refuel 99999")
  4. local fuel = turtle.getFuelLevel()
  5. local item
  6.  
  7. -- ########################
  8. -- OPTIONS SECTION
  9.  
  10. term.clear()
  11. print("               ")
  12. print("               ")
  13. print("  [][][]   ^   ")
  14. print("  [][][]   |   ")
  15. print("  [][][]   |   ")
  16. print("               ")
  17. print("Length: ")
  18.     length = read()
  19.     length = tonumber(length)
  20. term.clear()
  21. print("               ")
  22. print("  ---->        ")
  23. print("  [][][]       ")
  24. print("  [][][]       ")
  25. print("  [][][]       ")
  26. print("               ")
  27. print("Width: ")
  28.     width = read()
  29.     width = tonumber(width)
  30. term.clear()
  31.  
  32. totalBlocks = length * width
  33. lengthDug = 1
  34. widthDug = 1
  35. blocksDug = 0
  36.  
  37. -- ########################
  38. -- FUNCTIONS SECTION
  39.  
  40. function digL()
  41.     if turtle.detectDown() then
  42.         turtle.digDown()
  43.         tryForward()
  44.         blocksDug = blocksDug + 1
  45.         lengthDug = lengthDug + 1
  46.     else
  47.         tryForward()
  48.         blocksDug = blocksDug + 1
  49.         lengthDug = lengthDug + 1
  50.     end
  51.     term.clear()
  52.     print("Fuel remaining: "..fuel.."")
  53.     print("blocks Dug: "..blocksDug.." / "..totalBlocks.."")
  54. end
  55.  
  56. function digW()
  57.     if turtle.detectDown() then
  58.         turtle.digDown()
  59.         tryForward()
  60.         blocksDug = blocksDug + 1
  61.         widthDug = widthDug + 1
  62.     else
  63.         tryForward()
  64.         blocksDug = blocksDug + 1
  65.         widthDug = widthDug + 1
  66.     end
  67.     term.clear()
  68.     print("Fuel remaining: "..fuel.."")
  69.     print("blocks Dug: "..blocksDug.." / "..totalBlocks.."")
  70. end
  71.  
  72. function tryForward()
  73.     if not turtle.forward() then
  74.     sleep(1)
  75.         if turtle.detect() then
  76.             turtle.dig()
  77.         end
  78.     tryForward()
  79.     end
  80.     print("blocks Dug: "..blocksDug.." / "..totalBlocks.."")
  81. end
  82.  
  83. -- ########################
  84. -- MAIN CODE
  85.  
  86. while (blocksDug < totalBlocks) do
  87. --  while (lengthDug < length) do
  88. --      digL()
  89. --  end
  90. --      lengthDug = 0
  91. --      turtle.turnRight()
  92. --  while (widthDug < width) do
  93. --      digW()
  94. --  end
  95. --      widthDug = 0
  96. --      turtle.turnRight()
  97.     while (lengthDug < length) do
  98.         digL()
  99.     end
  100.         lengthDug = 1
  101.         length = length - 1
  102.         turtle.turnRight()
  103.     while (widthDug < width) do
  104.         digW()
  105.     end
  106.         widthDug = 1
  107.         width = width - 1
  108.         turtle.turnRight()
  109. end
  110.  
  111. sleep(0.1)
  112. print("Done.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement