View difference between Paste ID: kAzjsA4S and 2AzkY2Vr
SHOW: | | - or go back to the newest paste.
1
--Variables and Functions
2
tool = "left"
3
weapon = "right"
4
5
function moveForward()
6
    while not turtle.forward() do
7
        if not turtle.detect() then
8
            turtle.attack(weapon)
9
        else
10
            turtle.dig(tool)
11
        end
12
    end
13
end
14
15
function mineOneChunkLayer()
16
    --Starter Postion Length of 15
17
    for i=1,14 do
18
        if turtle.detectDown() then
19
            turtle.digDown(tool)
20
        end
21
        moveForward()
22
    end
23
    turtle.digDown(tool)
24
    turtle.turnRight()
25
    moveForward()
26
    turtle.turnRight()
27
    --Full Chunk Length of 16
28
    local turnDir = "l"
29
    for i=1,15 do
30
        for i=1,15 do  
31
            if turtle.detectDown() then
32
                turtle.digDown(tool)
33
            end
34
            moveForward()
35
        end
36
        
37
        if i == 15 then
38
            turtle.turnRight()
39
        else
40
            if turnDir == "l" then
41
                turtle.digDown(tool)
42
                turtle.turnLeft()
43
                moveForward()
44
                turtle.turnLeft()
45
                turnDir = "r"
46
            else
47
                turtle.digDown(tool)
48
                turtle.turnRight()
49
                moveForward()
50
                turtle.turnRight()
51
                turnDir = "l"
52
            end
53
        end
54
    end
55
    --Return to item processor and
56
    --Dump all items
57
    for i=1,14 do
58
        moveForward()
59
    end
60
    for i=1,16 do
61
        turtle.select(i)
62
        turtle.drop()
63
    end
64
    turtle.turnRight()
65
    moveForward()
66
    turtle.turnLeft()
67
    moveForward()
68
    turtle.turnRight()
69
    turtle.down()
70
end    
71
72
term.clear()
73
term.setCursorPos(1,1)
74
write("Turtle Y Position: ")
75
turtleY = tonumber(read())
76
print(" ")
77
write("Target Y Position: ")
78
targetY = tonumber(read())
79
80
diffY = turtleY - targetY
81
82
print(" ")
83
print("Mining Chunk!")
84
for i=1, diffY-1 do
85
    mineOneChunkLayer()
86
end