daily pastebin goal
39%
SHARE
TWEET

mineTunnel

a guest Nov 18th, 2017 282 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. tArgs = {...}
  2. height = tArgs[1]
  3. length = tArgs[2]
  4.  
  5. if not tArgs[1] or not tArgs[2] then
  6.   print("Usage: mineTunnel height length")
  7.   return(0)
  8. end
  9.  
  10. --if height <= 1 then
  11. --  print("Height must be aleast 2. Setting it to 2")
  12. --  height = 2
  13. --end
  14.  
  15. function refuel()
  16.   if turtle.getFuelLevel() < 1 then
  17.     print("Refueling")
  18.     turtle.select(1)
  19.     turtle.refuel()    
  20.   end
  21. end
  22.  
  23. function torch(spacing)
  24.   turtle.select(3)
  25.   if math.fmod(spacing,5) == 0 then
  26.     print("Placing torch")
  27.     turtle.turnLeft()
  28.     turtle.turnLeft()
  29.     turtle.place()
  30.     turtle.turnRight()
  31.     turtle.turnRight()
  32.   end
  33. end
  34.  
  35. function dig(far,tall)
  36.   for i=1, far do
  37.     refuel()
  38.     while turtle.detect() do
  39.       turtle.dig()
  40.     end
  41.     turtle.forward()
  42.     for j=1, tall do
  43.       while turtle.detectUp() do
  44.         turtle.digUp()
  45.       end
  46.       turtle.up()
  47.     end
  48.     for j=1, tall do
  49.       turtle.down()
  50.     end
  51.   torch(i)
  52.   end  
  53. end
  54.  
  55. function unload(far)
  56.   turtle.turnLeft()
  57.   turtle.turnLeft()
  58.   turtle.up()
  59.   for i=1, far do
  60.     turtle.forward()
  61.   end
  62.   turtle.down()
  63.   turtle.select(2)
  64.   turtle.place()
  65.   for i=4, 16 do
  66.     turtle.select(i)
  67.     turtle.drop()
  68.   end
  69.   turtle.turnLeft()
  70.   turtle.turnLeft()
  71. end
  72.  
  73. function check()
  74.   turtle.select(1)  
  75.   local data = turtle.getItemDetail()
  76.   if not data then
  77.     print("Please put coal in slot 1")
  78.     error()
  79.   elseif data.name ~= "minecraft:coal" then
  80.     print("Please put coal in slot 1")
  81.     error()
  82.   end
  83.   turtle.select(2)
  84.   data = turtle.getItemDetail()
  85.   if not data then
  86.     print("Please put a chest in slot 2")
  87.     error()
  88.   elseif data.name ~= "minecraft:chest" then
  89.     print("Please put a chest in slot 2")
  90.     error()
  91.   end
  92. end
  93.  
  94. check()
  95. dig(length,height)
  96. unload(length)
  97. print("Done")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top