Advertisement
Guest User

tsukiMine_v0.3

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