• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jun 16th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. -- get arguments
2.
3. local tArgs = { ... }
4. if #tArgs ~= 1 then
5.     print( "Usage: basicTunne; <Tunnel Length>" )
6.     return
7. end
8.
9. local tunnelLength = tonumber( tArgs[1] )
10. if tunnelLength < 1 then
11.     print( "Tunnel Length must be positive!" )
12.     return
13. end
14.
15. -- function to tunnel 1x3 directly in front
16.
17. local function digInFront ()
18.
19.     if turtle.detectUp() then
20.         if turtle.digUp() then
21.             turtle.suckDown()
22.         end
23.     end
24.
25.     if turtle.detect() then
26.         if turtle.dig() then
27.             turtle.suckDown()
28.         end
29.     end
30.
31.     if turtle.detectDown() then
32.         if turtle.digDown() then
33.             turtle.suckDown()
34.         end
35.     end
36. end
37.
38. -- function to move x blocks in given direction (left / right) maintaining orientation
39. local function move(numToMove, orientation)
40.     local cleanNumToMove = tonumber( numToMove )
41.
42.     if orientation == "left" then
43.         if turtle.turnLeft() then
44.             for i = 0, cleanNumToMove, 1 do
45.                 turtle.forward()
46.             end
47.             turtle.turnRight()
48.         end
49.     end
50.
51.     if orientation == "right" then
52.         if turtle.turnRight() then
53.             for i = 0, cleanNumToMove, 1 do
54.                 turtle.forward()
55.             end
56.             turtle.turnLeft()
57.         end
58.     end
59.
60. end
61.
62. -- program start
63.
64. local done = false
65.
66. while not done do
67.     for n = 0, tunnelLength/2 do
68.
69.         digInFront()
70.         move(1, "right")
71.         digInFront()
72.         move(1, "right")
73.         digInFront()
74.
75.         turtle.forward()
76.
77.         digInFront()
78.         move(1, "left")
79.         digInFront()
80.         move(1, "left")
81.         digInFront()
82.     end
83.     done = true
84. end
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.

Top