zaboodable

MineLineDeluxe

Apr 3rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. local tArgs = {...}
  2. local length = tonumber(tArgs[1]) or 100
  3. print("Length " .. length)
  4.  
  5. -- Turtle Vars
  6. local dist = 0
  7. local dir = 0
  8. local iterations = tonumber(tArgs[2]) or 1
  9.  
  10.  
  11. if (tArgs[3] == "left" or tArgs[3] == "l") then
  12.   dir = 0
  13. else
  14.   dir = 1
  15. end
  16.  
  17. function Dig()
  18.   while (turtle.detect()) do
  19.     turtle.dig()
  20.     sleep(0.5)
  21.   end
  22. end
  23.  
  24. function DigUp()
  25.   while (turtle.detectUp()) do
  26.     turtle.digUp()
  27.     sleep(0.5)
  28.   end
  29. end
  30.  
  31. function DigStep()
  32.   Dig()
  33.   turtle.forward()
  34.   DigUp()
  35.   dist = dist + 1
  36. end
  37.  
  38. function TurnAround(direction)
  39.   if (direction == 1) then
  40.     turtle.turnRight()
  41.   else
  42.     turtle.turnLeft()
  43.   end
  44.   DigStep()
  45.   DigStep()
  46.   DigStep()
  47.   if (direction == 1) then
  48.     turtle.turnRight()
  49.     dir = 0
  50.   else
  51.     turtle.turnLeft()
  52.     dir = 1
  53.   end
  54. end
  55.  
  56. -- Main
  57. for i = 1, iterations do
  58.   for j = 1, length do
  59.     DigStep()
  60.   end
  61.   TurnAround(dir)
  62.   for j = 1, length do
  63.     DigStep()
  64.   end
  65.   TurnAround(dir)
  66. end
Add Comment
Please, Sign In to add comment