View difference between Paste ID: ndzx4WZN and he0GbPzT
SHOW: | | - or go back to the newest paste.
1
-- Kompatibel mit TurtleOS 1.5
2-
-- Standardtunnel 1x2
2+
-- Standardtunnel 1x2 mit Return und Quergang
3
4
TunnelLaenge=50
5
QuerTunnelLaenge=2
6
FackelEntfernung=8
7
TunnelZurueckgelegt=0
8
9
--############################
10
11
function turnAround()
12
    turtle.turnRight() 
13
    turtle.turnRight() 
14
end
15
16
function placeTorch()
17
    if TunnelZurueckgelegt%FackelEntfernung==2 then
18
        turnAround()
19
        if turtle.getItemCount(16)>0 then
20
            turtle.select(16) 
21
            turtle.place(X) 
22
        end
23
        turnAround()
24
    end
25
end
26
27
function refuel()
28
    turtle.select(15)
29
    if turtle.getItemCount(15)  == 0 then
30
        print ("Kein Treibstoff! (Slot 15)")
31
    end
32
33
    if turtle.getFuelLevel()<=50 then
34
    turtle.refuel(1)
35
    end
36
end
37
38
function up()
39-
    if turtle.detectUp() then
39+
    print ("UP")
40-
	print ("UP")
40+
    turtle.digUp() 
41-
        turtle.digUp() 
41+
42
43
function front() 
44
    print ("FRONT")
45-
function down()
45+
    turtle.dig() 
46
end
47-
        print ("FRONT")
47+
48-
        turtle.dig() 
48+
function checkMiningUp()
49
    if turtle.detectUp() then 
50
        return true
51
    end
52
    return false
53
end
54
55
function checkMiningFront()
56
    if turtle.detect() then 
57-
        -- oben abbauen
57+
        return true
58-
        up()
58+
59-
        --vorne abbauen
59+
    return false
60-
        down()
60+
61
62
function checkMining()
63
    if turtle.detect() or turtle.detectUp() then 
64
        return true
65
    end
66
    return false
67
end
68
69
function tunnel(tunnelentf)
70
    while tunnelentf>TunnelZurueckgelegt do
71
        print ("StartSchleife")
72
        -- nachfuellen
73
        refuel()
74
        while checkMining() do
75
            -- oben abbauen
76
            if checkMiningUp() then
77
                up()
78
            end
79-
    while entf>=x do
79+
            --vorne abbauen
80
            if checkMiningFront() then
81
                front()
82
            end
83
        end
84
        --1 vorgehen
85
        turtle.forward() 
86
        TunnelZurueckgelegt= TunnelZurueckgelegt + 1 --boah was 'ne kacksprache die kein ++ increment zulaesst
87
88
        -- Fackeln platzieren
89
        placeTorch()
90-
go 2
90+
91
    up()
92
    TunnelZurueckgelegt=0
93
end
94
95
function querTunnel(tunnelentf)
96
    turtle.turnRight()
97
    tunnel(tunnelentf)
98
    turtle.turnRight()
99
end
100
101
function go(entf)
102
    x=0
103
    while entf>x do
104
        turtle.forward()
105
        x=x+1
106
    end 
107
end
108
--############################
109
110
print ("Anfang")
111
tunnel(TunnelLaenge)
112
querTunnel(5)
113
turtle.turnRight()
114
go(2)
115
turtle.turnLeft()
116
tunnel(TunnelLaenge)
117
turnAround()
118
print ("Programmende")