View difference between Paste ID: 0gCW6AMP and hYABpV27
SHOW: | | - or go back to the newest paste.
1
--[[
2
2016 (c) psychedelixx
3
Minecraft Spiralstairs (robust)
4
2016-10-14
5
6-
Mines a 3x3 spiral stairs (downwards)
6+
Mines a spiral stairs (downwards left)
7
8
Robust API:
9
http://computercraft.info/wiki/Robust_Turtle_API
10
11
Usage: 
12
    - use turtle and type "label set <name>"
13
      (to give your turtle an unique name so it remembers its programs)
14-
    - type "pastebin get hYABpV27 spiralstairs"
14+
    - type "pastebin get 0gCW6AMP spiralstairs"
15-
    - type "spiralstairs <removeCenter 0|1>"
15+
    - type "spiralstairs <size>"
16
- place stairs in slot 14    
17
- place chests in slot 15
18
- place torches in slot 16
19
]]
20
stairsSlot = 14
21
chestSlot = 15
22-
centerRemoved = false
22+
23
 
24
function placeChestIfFull()
25
	empty = 0      
26-
	for slot = 1, 14 do
26+
	for slot = 1, 13 do
27
		if turtle.getItemCount(slot) == 0 then
28
			empty = 1
29
			break
30
		end
31
	end
32
33
	--[[ if turtle is full, turn around, place chest, move items into it, turn around and continue ]]--
34
	if empty == 0 then    
35
		t.up()
36
		t.turnAround()
37
		t.dig()
38
39
		if turtle.getItemCount(chestSlot) == 0 then
40
			print("Please put chests in slot 15 and press enter to continue")
41
			read()
42
		end
43
   
44
		turtle.select(chestSlot)
45
		turtle.place()
46
	   
47-
		for slot = 1, 14 do
47+
		for slot = 1, 13 do
48
			turtle.select(slot)
49
			turtle.drop()
50
		end
51
		   
52
		t.turnAround()
53
		t.down()
54
	end
55
end
56
 
57
local args = { ... }
58
59
if #args ~= 1 then
60-
	print("Usage: spiralstairs <removeCenter 0|1>")
60+
	print("Usage: spiralstairs <size>")
61
	print("place stairs in slot 14")
62
	print("place chests in slot 15")
63
	print("place torches in slot 16")
64
	error()
65
end
66-
if tonumber(args[1]) == 1 then
66+
67-
	removeCenter = true
67+
68-
else
68+
69-
	removeCenter = false
69+
	if (x+1)%13 == 0 and turtle.getItemCount(torchSlot) > 0 then
70
		oldSlot = turtle.getSelectedSlot()
71
		
72-
function removeCenterIfNeeded(x)
72+
73
		t.place(torchSlot)
74-
    if x%2 == 1 and removeCenter and not centerRemoved then
74+
75-
        t.left()
75+
76-
        t.dig()
76+
77-
        t.right()
77+
78
end	
79-
		centerRemoved = true
79+
80-
    end
80+
81
print("Let's go!")
82
print("Mining spiral stairs...")
83
84
if turtle.getItemCount(chestSlot) == 0 then
85-
	if (x+1)%14 == 0 and turtle.getItemCount(torchSlot) > 0 then
85+
86
	print("Warning: no chests found in slot 15. Press enter to continue")
87
	read()
88
end
89
90
if turtle.getItemCount(torchSlot) == 0 then
91
	print("")
92
	print("Warning: no torches found in slot 16. Press enter to continue")
93
	read()
94
end
95
96
x = 0
97
done = false
98
99
repeat
100
	t.dig()
101
	t.forward()
102
	placeChestIfFull()
103
    
104
    t.digUp()
105
    t.up()    
106
    t.placeDown(stairsSlot)
107
    
108
	x = x + 1
109
	
110
	placeTorchIfNeeded(x)
111
112
	if x%(tonumber(args[1])-1) == 0 then
113
		t.right()
114
	end
115-
t.digDown()
115+