Advertisement
Guest User

tsukiMine_v0.1

a guest
Jan 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.81 KB | None | 0 0
  1. -- Read the cycle count.
  2. local cycleCount
  3. local inFront, blockInfo = turtle.inspect()
  4.  
  5. print("How many cycles to run?")
  6. cycleCount = read()
  7.  
  8. -- Run the cycle.
  9. for i = 1, cycleCount, 1 do
  10.  
  11.   -- Print the current cycle number.
  12.   print("Running cycle number "..i..".")
  13.  
  14.   digSuckMove('Forward')
  15.   digSuckMove("Up")
  16.   digSuckMove("Up")
  17.   turtle.turnLeft()
  18.  
  19.   for i2 = 1, 3, 1 do
  20.     turtle.dig()
  21.     turtle.down()
  22.   end
  23.  
  24.   turtle.turnRight()
  25.   turtle.turnRight()
  26.  
  27.   for i2 = 1, 3, 1 do
  28.     turtle.dig()
  29.     turtle.up()
  30.   end
  31.  
  32.   turtle.down()
  33.   turtle.down()
  34.  
  35. -- End of for.  
  36. end
  37.  
  38. print("Run completed successfuly! Returning to base!")
  39. returnToStart()
  40.  
  41. print("Returned to starting position! Press any button to clear screen!");
  42. os.pullEvent('key')
  43. term.clear()
  44. term.setCursorPos(1,1)
  45.  
  46. -- Prevent instant termination.
  47. -- read()
  48.  
  49. -- Functions.
  50. function digSuckMove(direction)
  51.     if direction == "up" then
  52.         if turtle.detect() == true then
  53.             print("Block above! Mining, picking up and moving up!")
  54.             turtle.digUp()
  55.             turtle.suckUp()
  56.             turtle.up()
  57.         else
  58.             print("Nothing above! Moving up!")
  59.             turtle.up()
  60.         end
  61.        
  62.     elseif direction == "down" then
  63.         if turtle.detectDown() == true then
  64.             print("Block below! Mining, picking up and moving down!")
  65.             turtle.digDown()
  66.             turtle.suckDown()
  67.             turtle.Down()
  68.         else
  69.             print("Nothing below! Moving down!")
  70.             turtle.Down()
  71.         end
  72.    
  73.     elseif direction == "forward" then
  74.         if turtle.detect() == true then
  75.             print("Block in front! Mining, picking up and moving forward!")
  76.             turtle.dig()
  77.             turtle.suck()
  78.             turtle.forward()
  79.         else
  80.             print("Nothing in front! Moving forward!")
  81.             turtle.forward()
  82.         end
  83.     else
  84.         print("Invalid argument!")
  85.     end
  86. end
  87.  
  88. function returnToStart()
  89.     for i3 = 1, cycleCount, 1 do
  90.         turtle.back()
  91.     end
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement