Advertisement
JumboData1668

Make holes

Mar 3rd, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. local tArgs = {...}
  2. local holes = tArgs[1]
  3. local firstItem,lastItem = 4,13
  4. local Ypos = 64
  5. local temp = 0
  6. term.setCursorPos(1,1)
  7. term.clear()
  8. if #tArgs == 1 then
  9.     print("Ok, I am going to make "..holes.." holes!")
  10.     print("To cansel hold Ctrl + T in 1 second")
  11.     sleep(5)
  12. else
  13.     print("Error!")
  14.     print("Wrong amount of arguments! This program only support 1 argument")
  15.     print()
  16.     print("Argument 1 = Holes you want to dig")
  17.     holes = 0
  18. end
  19.  
  20. function fuel()
  21.   if turtle.getFuelLevel() <= 10 then
  22.     turtle.select(16)
  23.     turtle.refuel(1)
  24.   end
  25. end
  26.  
  27. function isValuable()
  28.  
  29.   for i=1,3 do
  30.     turtle.select(i)
  31.     if turtle.detect() == false or turtle.compare() then
  32.         return false
  33.     end
  34.   end
  35.   return true
  36. end
  37.  
  38. function checkWalls(dep)
  39.   for j=1,4 do
  40.     if isValuable() then
  41.       turtle.dig()
  42.     end
  43.     turtle.turnRight()
  44.   end
  45. end
  46.  
  47. function putAwayInventory()
  48.     turtle.select(15)
  49.     turtle.place()
  50.     for i=firstItem,lastItem do
  51.         turtle.select(i)
  52.         turtle.drop()
  53.     end
  54. end
  55.  
  56. -- ( Program Start ) --
  57.  
  58.  
  59. for h = 1,holes do
  60.     fuel()
  61.     local depth = 1
  62.    
  63.     turtle.digDown()
  64.     turtle.down()
  65.     turtle.digDown()
  66.     while turtle.detectDown() == false do
  67.     fuel()
  68.     turtle.down()
  69.     depth = depth + 1
  70.     checkWalls(depth)
  71.     turtle.digDown()
  72.     end
  73.    
  74.     for k=1,depth do
  75.     fuel()
  76.     turtle.up()
  77.     end
  78.    
  79.     turtle.select(14)
  80.     turtle.placeDown()
  81.     turtle.turnRight()
  82.     putAwayInventory()
  83.     turtle.turnLeft()
  84.     turtle.forward()
  85.     turtle.forward()
  86.     turtle.turnRight()
  87.     turtle.forward()
  88.     turtle.turnLeft()
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement