View difference between Paste ID: cMBykysF and YijBG3sz
SHOW: | | - or go back to the newest paste.
1
--[[
2-
	2013 (c) psychedelixx
2+
	2014 (c) psychedelixx
3-
	Minecraft Turtle: Chest Tunnel
3+
	Minecraft Turtle: Chest Tunnel (Robust)
4-
	2013-05-22
4+
	2014-03-25
5
6-
	Digs a room with specified dimensions.
6+
	Digs a tunnel and places mined items in chests.
7
8
	Robust API:
9
	http://computercraft.info/wiki/Robust_Turtle_API
10
11-
        - type "pastebin get YijBG3sz ctunnel "
11+
12-
        - type "ctunnel <length> [<return (0|1)>]"
12+
13
          (to give your turtle an unique name so it remembers its programs)
14
        - type "pastebin get cMBykysF ct"
15
        - type "ct <length> [<return (0|1)>]"
16
		- place chests in slot 15
17
		- place torches in slot 16
18-
ret = 0
18+
19
os.loadAPI("t")
20
i = 0
21
ret = 1
22-
	if turtle.getFuelLevel() < 2 then 
22+
23-
		turtle.refuel() 
23+
24
	i = i+1
25
	
26
	print("----------------")
27
	print("Remaining fuel: " .. turtle.getFuelLevel())
28
	print("Digged: " .. i .. "/" .. length .. "(" .. math.floor(100/length*i) .. "%)")
29
	print("Next torch in " .. 9-i%8)
30
	print("Next chest in " .. 33-i%32)
31
	print("")
32
	
33
	--[[ Vorwärts graben und bewegen ]]--
34-
	while not turtle.forward() do
34+
	t.dig()
35-
		turtle.dig()
35+
	t.forward()
36
	
37
	--[[ Hoch bzw. runter graben ]]--
38
	if i%2 == 1 then
39
		t.digUp()
40-
		repeat
40+
41-
			turtle.digUp()
41+
		t.digDown()
42-
		until not turtle.detectUp()
42+
43
	
44-
		turtle.digDown()
44+
45
	t.left()
46
	t.dig()
47
	
48-
	turtle.turnLeft()
48+
49-
	repeat
49+
50-
		turtle.dig()
50+
51-
	until not turtle.detect()
51+
52
		for slot = 1, 14 do
53
			turtle.select(slot)
54
			turtle.drop()
55
		end
56
	end
57
	
58
	--[[ Rechts graben ]]--
59
	t.turnAround()
60
	t.dig()
61
	
62
	--[[ Fackel setzen ]]--
63
	if i%8 == 1 then
64-
	turtle.turnLeft()
64+
65-
	turtle.turnLeft()
65+
66-
	repeat
66+
67-
		turtle.dig()
67+
68-
	until not turtle.detect()
68+
69
	if i%2 == 1 then
70
		t.up()
71
		t.digUp()
72
	else	
73
		t.digUp()
74
		t.down()
75
	end
76
	
77
	--[[ Rechts graben ]]--
78-
		turtle.digDown()
78+
	t.dig()
79-
		turtle.up()
79+
80-
		repeat
80+
81-
			turtle.digUp()
81+
	t.turnAround()
82-
		until not turtle.detectUp()
82+
	t.dig()
83
	
84-
		repeat
84+
85-
			turtle.digUp()
85+
	t.right()	
86-
		until not turtle.detectUp()
86+
87-
		turtle.down()
87+
	--[[ Sand/Kies entfernen ]]--
88-
		turtle.digDown()
88+
	t.digUp()
89
end
90
91
local args = { ... }
92-
	repeat
92+
93-
		turtle.dig()
93+
94-
	until not turtle.detect()
94+
	print("ct <length> [<return (0|1)>]")
95
	print("place chests in slot 15")
96
	print("place torches in slot 16")
97-
	turtle.turnLeft()
97+
98-
	turtle.turnLeft()
98+
99-
	repeat
99+
100-
		turtle.dig()
100+
101-
	until not turtle.detect()
101+
102
length = tonumber(args[1])
103
104-
	turtle.turnRight()	
104+
105
	ret = tonumber(args[2])
106
end
107
108
if turtle.getFuelLevel() < length*2 + length*ret then
109
	print("I need fuel!")
110-
	print("ctunnel <length> [<return (0|1)>]")
110+
	print((length*2 + length*ret) - turtle.getFuelLevel() .. " fuel missing")
111
	print("Refuel with " .. ((length*2 + length*ret) - turtle.getFuelLevel())/80+1 .. " pieces of coal")
112
else
113
	print("======== 2014 (c) psychedelixx ========")
114
	print("Let's go!")
115
	print("Digging " .. length)
116
	
117
	for l = 1, length do
118
		move()
119
	end
120
	
121-
	ret = 1
121+
122
		t.turnAround()
123
		t.forward(length)
124-
if turtle.getFuelLevel() == 0 then
124+
125-
	turtle.refuel()
125+