View difference between Paste ID: p6iS61VQ and QXAS2Afp
SHOW: | | - or go back to the newest paste.
1-
local CRAFT_BATCH_SIZE = 16;
1+
2-
local CRAFT_SLEEP_WAIT = 2;
2+
	local timer = os.startTimer(5)
3
    local event = os.pullEvent()
4-
local craftTable = {
4+
5-
    {"f", "t", 0, 0},
5+
	if event ~= "redstone" and event ~= "timer" then
6-
    {0, 0, 0, 0},
6+
		return
7-
    {0, 0, 0, 0},
7+
	end
8-
    {0, 0, 0, 0}
8+
	
9-
}
9+
	if event == "redstone" then
10
		if not redstone.getInput("bottom") and not redstone.getInput("left") then
11-
function cleanUpInventory()
11+
			return
12-
    print("[cr] cleaning up the inventory")
12+
		end
13-
    for i=1,16 do
13+
	end
14-
        turtle.select(i)
14+
15-
        turtle.dropDown()
15+
	os.cancelTimer(timer)
16
	print("[cr] caught event")
17
	sleep(0.1)
18
19-
function loadIngridient(slot, direction)
19+
	print("[cr] pushing piston")
20-
    if direction == 0 then
20+
	redstone.setOutput("right", true)
21-
        return
21+
	sleep(0.1)
22
23
	print("[cr] retracting piston")
24-
    print("[cr] loading item to slot " .. slot)
24+
	redstone.setOutput("right", false)
25-
    turtle.select(slot)
25+
	sleep(0.3)
26
end
27-
    local res
27+
28-
    local count = turtle.getItemCount()
28+
29
    print("\n\n-------------------------------")
30-
    if direction == "t" then
30+
31-
        res = turtle.suckUp(CRAFT_BATCH_SIZE - count)
31+
32-
    elseif direction == "b" then
32+
33-
        res = turtle.suckDown(CRAFT_BATCH_SIZE - count)
33+
34-
    elseif direction == "f" then
34+
35-
        res = turtle.suck(CRAFT_BATCH_SIZE - count)
35+
36
end
37
38-
    if not res then
38+