Advertisement
Guest User

Tunneler.lua

a guest
Feb 17th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. -- 3x3 Tunnel and Block Placer --
  2. --[[
  3.     This program creates a 3x3 tunnel with
  4.     specifc blocks.
  5. --]]
  6.  
  7. -- Configuration --
  8. local length = 21 -- Do not set more than 21 blocks
  9.  
  10. --Fuction Definitions --
  11. local function digCenterLine() --Digs Centerline of Tunnel
  12.     while turtle.detect() do
  13.         turtle.dig()
  14.     end
  15.     turtle.forward()
  16.     while turtle.detectUp() do
  17.         turtle.digUp()
  18.         os.sleep(0.5)
  19.     end
  20.     turtle.digDown()
  21. end
  22.  
  23. local function turnAround()
  24.     turtle.turnRight()
  25.     turtle.turnRight()
  26. end
  27.  
  28. local function placeSideBlock(block)
  29.     digCenterLine()
  30.     if not turtle.detectDown() then
  31.         turtle.select(block)
  32.         turtle.placeDown()
  33.     end
  34.     if not turtle.detectUp() then
  35.         turtle.select(block)
  36.         turtle.placeUp()
  37.     end
  38.     turtle.back()
  39.     turtle.select(block)
  40.     turtle.place()
  41. end
  42.  
  43. local function placeBottomBlock()
  44.     if turtle.detectDown() then
  45.         turtle.digDown()
  46.         os.sleep(0.5)
  47.     end
  48.     turtle.select(3)
  49.     turtle.placeDown()
  50. end
  51.  
  52. local function placeTopBlock()
  53.     if turtle.detectUp() then
  54.         turtle.digUp()
  55.         os.sleep(0.5)
  56.     end
  57.     turtle.select(4)
  58.     turtle.placeUp()
  59. end
  60.  
  61. local function digTunnel()
  62.     digCenterLine()
  63.     turtle.turnLeft()
  64.     digCenterLine()
  65.     placeSideBlock(1)
  66.     turnAround()
  67.     turtle.forward()
  68.     digCenterLine()
  69.     placeSideBlock(2)
  70.     turnAround()
  71.     turtle.down()
  72.     placeBottomBlock()
  73.     turtle.forward()
  74.     placeBottomBlock()
  75.     turtle.forward()
  76.     placeBottomBlock()
  77.     turnAround()
  78.     turtle.up()
  79.     turtle.up()
  80.     placeTopBlock()
  81.     turtle.forward()
  82.     placeTopBlock()
  83.     turtle.forward()
  84.     placeTopBlock()
  85.     turnAround()
  86.     turtle.forward()
  87.     turtle.down()
  88.     turtle.turnRight()
  89. end
  90.  
  91. -- Program --
  92. turtle.up()
  93. for i=0, length - 1 do
  94.     digTunnel()
  95.     if i % 7 == 0 then
  96.         turtle.up()
  97.         turtle.digUp()
  98.         turtle.select(5)
  99.         turtle.placeUp()
  100.         turtle.down()
  101.     end
  102. end
  103. turtle.down()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement