View difference between Paste ID: gLBDsFpm and VyBDnvbc
SHOW: | | - or go back to the newest paste.
1-
local component = require("component")
1+
p = peripheral.wrap("right")
2-
local sides = require("sides")
2+
t = peripheral.wrap("top")
3-
-- Main output side
3+
4-
f = sides.forward
4+
suund = 'west'
5-
-- Main input sides
5+
inv_size = p.getInventorySize()
6-
u = sides.up
6+
location={}
7-
d = sides.down 
7+
function Main()
8-
-- What to craft
8+
end
9-
recipe = {}
9+
	
10-
recipe["double_cobblestone"]={
10+
function jahu()
11-
    [1]='minecraft:cobblestone',
11+
	for i=1, inv_size do
12-
    [2]='minecraft:cobblestone',
12+
		if p.getStackInSlot(i) ~=nil then
13-
    [3]='minecraft:cobblestone',
13+
		  if p.getStackInSlot(i)['id'] == 'harvestcraft:saltItem' then
14-
    [5]='minecraft:cobblestone',
14+
		   location['sool']={}
15-
    [6]='minecraft:cobblestone',
15+
		   location['sool']['asukoht']=i
16-
    [7]='minecraft:cobblestone',
16+
		   location['sool']['kogus']=p.getStackInSlot(i).qty
17-
    [9]='minecraft:cobblestone',
17+
		  elseif p.getStackInSlot(i)['id'] == 'Natura:barleyFood' or p.getStackInSlot(i)['id'] == 'EnderIO:itemPowderIngot' then
18-
    [10]='minecraft:cobblestone',
18+
		   location['jahu']={}
19-
    [11]='minecraft:cobblestone',   
19+
		   location['jahu']['asukoht']=i
20-
}
20+
		   location['jahu']['kogus']=p.getStackInSlot(i).qty
21-
moveStuff()
21+
		  end
22-
function moveStuff()
22+
		end
23-
    input_size = component.inventory_conroller.getInventorySize(sides.down)
23+
	end
24-
    for i=1, input_size do
24+
	if (location['sool']~=nil  and location['jahu']~=nil) then
25-
        print (component.inventory_controller.getStackInSlot(d,i))
25+
	  if location['sool']['kogus'] >= 3  and location['jahu']['kogus'] >= 3 then
26
		if location['sool']['kogus']>= location['jahu']['kogus']then
27
			kogus = location['jahu']['kogus']
28
		elseif location['sool']['kogus'] == location['jahu']['kogus']then
29
			kogus = location['sool']['kogus']
30
		elseif location['sool']['kogus'] == location['jahu']['kogus']then
31
			kogus = location['jahu']['kogus']
32
		end
33
		  if kogus > 0 then
34
			p.pushItemIntoSlot(suund,location['sool']['asukoht'],kogus,5)
35
			p.pushItemIntoSlot(suund,location['jahu']['asukoht'],kogus,6)
36
			asjadpaika('tainas')
37
			turtle.turnRight()
38
			  for i=1,kogus do
39
					veetaide()
40
					turtle.select(16)
41
					if turtle.craft() then
42
						if turtle.dropUp() then
43
						end
44
					end
45
					turtle.select(2)
46
			  end
47
			  
48
			  asjad_paigast('tainas')
49
		  end
50
	  end
51
	end
52
end
53
54
function findItems(id, amount, peripheral)
55
		sizeh=peripheral.getInventorySize()
56
	for i=1, sizeh do
57
		if peripheral.getStackInSlot(i).id == id and peripheral.getStackInSlot().qty >= amount then
58
			return true
59
		else
60
			return false
61
		end
62
	end
63
end
64
65
function canCraft(item)
66
	counts = {}
67
	for i=1, table.getn(item) do
68
		if item[i] ~= 0 then
69
			if counts[item[i]] ~= nil then
70
				counts[item[i]]["quant"] = counts[item[i]]["quant"] + 1
71
			else	
72
				counts[item[i]]["quant"] = 1
73
			end
74
		end
75
	end
76
end
77
78
axe = {0,"minecraft:cobblestone","minecraft:cobblestone",0,"minecraft:stick",0,0,"minecraft:stick",0,}
79
pick = {"minecraft:cobblestone","minecraft:cobblestone","minecraft:cobblestone",0,"minecraft:stick",0,0,"minecraft:stick",0,}
80
sword = {0,"minecraft:cobblestone",0,0,"minecraft:stick",0,0,"minecraft:stick",0,}
81
crafts = {[axe]=axe, [pick]=pick, [sword]=sword}
82
83
function craftsFile()
84
	if not fs.exists("/crafts") then
85
        print ("creating crafts file")
86
        local f = io.open("/crafts", "w")
87
        f:write(textutils.serialize(crafts))
88
        f:close()
89
	end
90
end
91
92
function veetaide()
93
    turtle.select(2)
94
    repeat
95
    until turtle.place() ~= false
96
end
97
function asjadpaika(asjad)
98
    if asjad == 'tainas' then
99
     turtle.turnLeft()
100
     os.sleep(1)
101
     tools =peripheral.wrap('front')
102
     tools.pushItemIntoSlot('east',1,1,1)
103
     tools.pushItemIntoSlot('east',2,1,2)
104
    end
105
end
106
107
function asjad_paigast(asjad)
108
		turtle.turnLeft()
109
    if asjad =='tainas' then
110
        os.sleep(1)
111
        turtle.select(1)
112
        turtle.drop()
113
        turtle.select(2)
114
        turtle.drop()
115
    end
116
    turtle.turnRight()
117
end
118
119
canCraft(axe)
120
for k,v in pairs(counts) do
121
	print(k.." = "..v)
122
end