View difference between Paste ID: hYABpV27 and 7Ckr8y7s
SHOW: | | - or go back to the newest paste.
1-
	--[[
1+
--[[
2-
	2015 (c) psychedelixx
2+
2016 (c) psychedelixx
3-
	Minecraft Turtle: Spiral miner (Robust)
3+
Minecraft Spiralstairs (robust)
4-
	2015-01-04
4+
2016-10-14
5
6-
	Mines in a spiralform (spin me right round baby) and stays on the level it started.
6+
Mines a 3x3 spiral stairs (downwards)
7
8-
	Robust API:
8+
Robust API:
9-
	http://computercraft.info/wiki/Robust_Turtle_API
9+
http://computercraft.info/wiki/Robust_Turtle_API
10
11-
	Usage: 
11+
Usage: 
12-
        - use turtle and type "label set <name>"
12+
    - use turtle and type "label set <name>"
13-
          (to give your turtle an unique name so it remembers its programs)
13+
      (to give your turtle an unique name so it remembers its programs)
14-
        - type "pastebin get 7Ckr8y7s spiral"
14+
    - type "pastebin get hYABpV27 spiralstairs"
15-
        - type "spiral <limit> [<fillGround 0|1 default 0> <factor default 1.5> <useTesseract 0|1 default 0>]"
15+
    - type "spiralstairs <removeCenter 0|1>"
16-
	- place chests in slot 16
16+
- place chests in slot 15
17-
	]]
17+
- place torches in slot 16
18-
torchesAvailable = false
18+
]]
19-
chestsAvailable = false
19+
20-
torchSlot = 15
20+
chestSlot = 15
21-
factor = 1.5
21+
torchSlot = 16
22-
useTesseract = false
22+
centerRemoved = false
23
 
24-
function move()
24+
function placeChestIfFull()
25-
	slot = 1
25+
	empty = 0      
26-
	while not turtle.detectDown() and fillGround == 1 do
26+
	for slot = 1, 14 do
27-
		turtle.select(slot)
27+
28-
		turtle.placeDown()
28+
29
			break
30-
		if slot < 13 then
30+
31-
			slot = slot+1
31+
32-
		else
32+
33-
			print("no items to fill ground")
33+
34-
			fillGround = 0
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-
	t.digUp()
41+
			read()
42
		end
43-
	empty = 0	
43+
   
44-
	for slot = 1, 13 do
44+
		turtle.select(chestSlot)
45
		turtle.place()
46
	   
47
		for slot = 1, 14 do
48
			turtle.select(slot)
49
			turtle.drop()
50
		end
51
		   
52-
	if empty == 0 then		
52+
53
		t.down()
54
	end
55-
        if not chestsAvailable then
55+
56-
            print("Please put chests in slot 15 and press enter to continue")
56+
57-
            read()
57+
58-
        end
58+
59-
        
59+
if #args ~= 1 then
60-
		turtle.select(14)
60+
	print("Usage: spiralstairs <removeCenter 0|1>")
61
	print("place chests in slot 15")
62
	print("place torches in slot 16")
63-
		for slot = 1, 13 do
63+
64-
				turtle.select(slot)
64+
65-
				turtle.drop()
65+
66
if tonumber(args[1]) == 1 then
67-
        
67+
	removeCenter = true
68-
        if useTesseract then
68+
69-
            os.sleep(0.5)
69+
	removeCenter = false
70-
            turtle.select(14)
70+
end	
71-
            turtle.dig()
71+
72-
        end
72+
function removeCenterIfNeeded(x)
73
   
74-
        if turtle.getItemCount(14) > 0 then
74+
    if x%2 == 1 and removeCenter and not centerRemoved then
75-
                chestsAvailable = true
75+
        t.left()
76-
        else
76+
        t.dig()
77-
                chestsAvailable = false
77+
        t.right()
78-
        end
78+
79
		centerRemoved = true
80
    end
81
end	
82
83
function placeTorchIfNeeded(x)
84
	
85-
if #args < 1 then
85+
	if (x+1)%14 == 0 and turtle.getItemCount(torchSlot) > 0 then
86
		oldSlot = turtle.getSelectedSlot()
87-
	print("spiral <limit> [<fillGround 0|1 default 0> <factor default 1.5> <useTesseract 0|1 default 0]")
87+
88-
	print("place chests/tesseract in slot 14")
88+
89-
	print("place torches in slots 15 and 16")
89+
		t.place(torchSlot)
90
		t.left()
91
		
92
		turtle.select(oldSlot)
93
	end	
94-
if #args >= 1 then
94+
end	
95-
	limit  = tonumber(args[1])
95+
96-
	fillGround = 0
96+
print("======== 2016 (c) psychedelixx ========")
97
print("Let's go!")
98-
if #args >= 2 then
98+
print("Mining spiral stairs...")
99-
	fillGround = tonumber(args[2])
99+
100
if turtle.getItemCount(chestSlot) == 0 then
101-
if #args >= 3 then
101+
102-
	factor= tonumber(args[3])
102+
	print("Warning: no chests found in slot 15. Press enter to continue")
103
	read()
104-
if #args >= 4 then
104+
105-
    if tonumber(args[4]) > 0 then
105+
106-
        useTesseract = true
106+
if turtle.getItemCount(torchSlot) == 0 then
107-
    else
107+
108-
        useTesseract = false
108+
	print("Warning: no torches found in slot 16. Press enter to continue")
109
	read()
110
end
111
112-
if turtle.getFuelLevel() < 0.75*limit*limit + limit then
112+
x = 0
113-
	print("I need " .. (0.75*limit*limit + limit) - turtle.getFuelLevel() .. " more fuel!")
113+
done = false
114
115-
	print("======== 2015 (c) psychedelixx ========")
115+
t.digDown()
116-
	print("Let's go!")
116+
t.down()
117-
	print("Mining a spiral...")
117+
118
repeat
119-
    if turtle.getItemCount(15)+turtle.getItemCount(16) > 0 then
119+
120-
        torchesAvailable = true
120+
	placeChestIfFull()
121-
    else
121+
122-
        print("")
122+
	x = x + 1
123-
        print("Warning: no torches found in slot 15 and 16. Press enter to continue")
123+
124-
        read()
124+
	removeCenterIfNeeded(x)
125-
        torchesAvailable = false
125+
126
	placeTorchIfNeeded(x)
127
128-
    if turtle.getItemCount(14) > 0 then
128+
	if x%2 == 0 then
129-
        chestsAvailable = true
129+
		t.left()
130-
    else
130+
131-
        print("")
131+
132-
        print("Warning: no chests found in slot 14. Press enter to continue")
132+
	if x%7 == 0 then
133-
        read()
133+
134-
        chestsAvailable = false
134+
135
		if turtle.detectDown() then
136
			if t.digDown() then
137-
    if turtle.getItemCount(15) > 0 then
137+
				placeChestIfFull()
138-
        torchesAvailable = true
138+
139-
        torchSlot = 15
139+
140-
    elseif turtle.getItemCount(16) > 0 then
140+
		if not t.down() then
141-
        torchesAvailable = true
141+
		    done = true
142-
        torchSlot = 16
142+
143-
    else    
143+
144-
        torchesAvailable = false
144+
		centerRemoved = false
145
	end
146
until done