Advertisement
Nunavailabul

xcavate

Mar 10th, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. --[[Author: Sandbag
  2.     Simple script that digs a hole, the size you specify.
  3.  
  4.     TO DO:
  5.         -better fuel management
  6.         -chest dumps
  7.         ]]
  8.  
  9.  
  10. function checkfuel()
  11. local fuel=tonumber(turtle.getFuelLevel())
  12.     if fuel < 70
  13.     then
  14.         print("************")
  15.         print("*")
  16.         print("*")
  17.                 print("* Need Fuel!!")     
  18.         print("*")
  19.         print("*")
  20.         print("* Place Coal in slot 1")
  21.         print("************")
  22.        
  23.     end
  24.  
  25. end
  26.  
  27. checkfuel()
  28.  
  29. io.write("Blocks in front of turtle? : ")
  30. y = tonumber(io.read())
  31.  
  32. io.write("Blocks to the right? : ")
  33. x = tonumber(io.read())
  34.  
  35. io.write("How Deep? : ")
  36. z = tonumber(io.read())
  37. --[ print (x..","..y..","..z) ]
  38.  
  39. function refueling()
  40.     print("Refueling from slot 1")
  41.     turtle.select(1)
  42.     turtle.refuel()
  43. end
  44.  
  45.  
  46.  
  47. function bore() --[dig down]
  48.     local depth = z
  49.     while depth > 0 do
  50.         turtle.digDown(1)
  51.         turtle.down(1)
  52.         depth = depth-1
  53.     end
  54.    
  55.     for i = 1 , z do
  56.         turtle.up()
  57.     end
  58. end
  59.  
  60. function ydig() --[dig out]
  61.     local ydig = y
  62.     while ydig > 0 do
  63.         bore()
  64.         if turtle.detect()
  65.             then
  66.             turtle.dig()
  67.         end
  68.         turtle.forward(1)
  69.         ydig = ydig-1
  70.     end
  71.    
  72.     for i = 1,y do
  73.         turtle.back()
  74.     end
  75.    
  76.    
  77. end
  78.  
  79.  
  80. function turn()
  81.     turtle.turnRight()
  82.     if turtle.detect()
  83.         then
  84.                     turtle.dig()
  85.             end
  86.     turtle.forward()
  87.     turtle.turnLeft()
  88. end
  89. function xcavate() --[dig across]
  90.     local xdig = tonumber(x)
  91.        
  92.     while xdig > 0 do  
  93.         if tonumber(turtle.getFuelLevel()) < 70
  94.             then
  95.                 refueling()
  96.             end
  97.         ydig()     
  98.         turn()
  99.         xdig = xdig-1
  100.     end
  101. end
  102.  
  103. xcavate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement