View difference between Paste ID: PrigiMmb and X2d2TJHN
SHOW: | | - or go back to the newest paste.
1-
--@author thor12022
1+
-- os.shutdown()
2-
local fieldSize = 8
2+
os.sleep(1200)
3
local fieldSize = 16
4-
-- It goes forever
4+
5-
while true do
5+
turtle.select(16)
6-
	-- if we need more fuel for this pass
6+
for i = 1,fieldSize+1,1 do
7-
	--TODO update for odd
7+
    turtle.forward()
8-
	if (isOdd and turtle.getFuelLevel() < ((fieldSize * fieldSize) + 2*fieldSize)) or (turtle.getFuelLevel() < ((fieldSize * fieldSize) + fieldSize)) then
8+
end
9-
		turtle.suckUp()
9+
for j = 1,4,1 do
10-
		turtle.refuel()
10+
    os.sleep(1)
11-
	end
11+
    turtle.turnLeft()
12-
	-- face outward 
12+
    for k = 1,fieldSize+1,1 do
13-
	turtle.turnLeft()
13+
        turtle.forward()
14-
	turtle.turnLeft()
14+
    end
15-
	-- loop over the rows
15+
    if(not turtle.compareUp()) then
16-
	local turnRight = true
16+
        break
17-
	for x = 1,fieldSize,1 do
17+
    end
18-
		-- loop over the columns (except the last one)
18+
end
19-
		for y = 1,fieldSize - 1,1 do
19+
20-
			turtle.digDown()
20+
-- if we need more fuel for this pass
21-
			turtle.placeDown()
21+
--TODO update for odd
22-
			turtle.forward()
22+
if (isOdd and turtle.getFuelLevel() < 2*((fieldSize * fieldSize) + 2*fieldSize)) or (turtle.getFuelLevel() < 2*((fieldSize * fieldSize) + fieldSize)) then
23-
		end
23+
    turtle.select(2)
24-
		-- harvest the last one
24+
    turtle.suckUp()
25-
		turtle.digDown()
25+
    turtle.refuel()
26-
		turtle.placeDown()
26+
end
27-
		-- all but the last row
27+
turtle.select(1)
28-
		if x ~= fieldSize then
28+
-- face outward 
29-
			-- turn right or left and change column
29+
turtle.turnLeft()
30-
			if turnRight == true then
30+
turtle.turnLeft()
31-
				turtle.turnRight()
31+
-- loop over the rows
32-
				turtle.forward()
32+
local turnRight = true
33-
				turtle.turnRight()
33+
for x = 1,fieldSize,1 do
34-
				turnRight = false
34+
    -- loop over the columns (except the last one)
35-
			else
35+
    for y = 1,fieldSize - 1,1 do
36-
				turtle.turnLeft()
36+
        turtle.digDown()
37-
				turtle.forward()
37+
        turtle.placeDown()
38-
				turtle.turnLeft()
38+
        turtle.forward()
39-
				turnRight = true
39+
    end
40-
			end
40+
    -- harvest the last one
41-
		end
41+
    turtle.digDown()
42-
	end
42+
    turtle.placeDown()
43-
	
43+
    -- all but the last row
44-
	-- face the starting point
44+
    if x ~= fieldSize then
45-
	turtle.turnRight()
45+
        -- turn right or left and change column
46-
	-- go back over the row if there was an odd size
46+
        if turnRight == true then
47-
	if isOdd then
47+
            turtle.turnRight()
48-
		turtle.turnRight()
48+
            turtle.forward()
49-
		for back = 1,(fieldSize-1),1 do
49+
            turtle.turnRight()
50-
			turtle.forward()
50+
            turnRight = false
51-
		end
51+
        else
52-
		turtle.turnRight()
52+
            turtle.turnLeft()
53-
	end
53+
            turtle.forward()
54-
	-- go back down the column
54+
            turtle.turnLeft()
55-
	for back = 1,(fieldSize-1),1 do
55+
            turnRight = true
56-
		turtle.forward()
56+
        end
57-
	end
57+
    end
58-
	-- face the chest
58+
end
59-
	turtle.turnLeft()
59+
60-
	--empty everything into the chest
60+
-- face the starting point
61-
	for slot = 1,16,1 do
61+
turtle.turnRight()
62-
		turtle.select(slot)
62+
-- go back over the row if there was an odd size
63-
		-- we keep trying to dump inventory
63+
if isOdd then
64-
		while turtle.getItemCount(slot) ~= 0 do
64+
    turtle.turnRight()
65-
			if not turtle.drop() then
65+
    for back = 1,(fieldSize-1),1 do
66-
				-- if the target inventory was full, we'll try it again later
66+
        turtle.forward()
67-
				os.sleep(10)
67+
    end
68-
			end
68+
    turtle.turnRight()
69-
		end
69+
end
70-
	end
70+
-- go back down the column
71-
	-- reset to the starting conditions
71+
for back = 1,(fieldSize-1),1 do
72-
	turtle.select(1)
72+
    turtle.forward()
73-
	-- go again in 45 minutes
73+
end
74-
	os.sleep(2400)
74+
-- face the chest
75-
end
75+
turtle.turnLeft()
76
--empty everything into the chest
77
for slot = 2,16,1 do
78
    turtle.select(slot)
79
    -- we keep trying to dump inventory
80
    while turtle.getItemCount(slot) ~= 0 do
81
        if not turtle.drop() then
82
            -- if the target inventory was full, we'll try it again later
83
            os.sleep(10)
84
        end
85
    end
86
end
87
-- reset to the starting conditions
88
turtle.select(1)
89
-- go again in 60 minutes
90
os.sleep(2400)
91
os.reboot()