Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p = peripheral.wrap("right")
- t = peripheral.wrap("top")
- suund = 'west'
- inv_size = p.getInventorySize()
- location={}
- function Main()
- end
- function jahu()
- for i=1, inv_size do
- if p.getStackInSlot(i) ~=nil then
- if p.getStackInSlot(i)['id'] == 'harvestcraft:saltItem' then
- location['sool']={}
- location['sool']['asukoht']=i
- location['sool']['kogus']=p.getStackInSlot(i).qty
- elseif p.getStackInSlot(i)['id'] == 'Natura:barleyFood' or p.getStackInSlot(i)['id'] == 'EnderIO:itemPowderIngot' then
- location['jahu']={}
- location['jahu']['asukoht']=i
- location['jahu']['kogus']=p.getStackInSlot(i).qty
- end
- end
- end
- if (location['sool']~=nil and location['jahu']~=nil) then
- if location['sool']['kogus'] >= 3 and location['jahu']['kogus'] >= 3 then
- if location['sool']['kogus']>= location['jahu']['kogus']then
- kogus = location['jahu']['kogus']
- elseif location['sool']['kogus'] == location['jahu']['kogus']then
- kogus = location['sool']['kogus']
- elseif location['sool']['kogus'] == location['jahu']['kogus']then
- kogus = location['jahu']['kogus']
- end
- if kogus > 0 then
- p.pushItemIntoSlot(suund,location['sool']['asukoht'],kogus,5)
- p.pushItemIntoSlot(suund,location['jahu']['asukoht'],kogus,6)
- asjadpaika('tainas')
- turtle.turnRight()
- for i=1,kogus do
- veetaide()
- turtle.select(16)
- if turtle.craft() then
- if turtle.dropUp() then
- end
- end
- turtle.select(2)
- end
- asjad_paigast('tainas')
- end
- end
- end
- end
- function findItems(id, amount, peripheral)
- sizeh=peripheral.getInventorySize()
- for i=1, sizeh do
- if peripheral.getStackInSlot(i).id == id and peripheral.getStackInSlot().qty >= amount then
- return true
- else
- return false
- end
- end
- end
- function canCraft(item)
- counts = {}
- for i=1, table.getn(item) do
- if item[i] ~= 0 then
- if counts[item[i]] ~= nil then
- counts[item[i]]["quant"] = counts[item[i]]["quant"] + 1
- else
- counts[item[i]]["quant"] = 1
- end
- end
- end
- end
- axe = {0,"minecraft:cobblestone","minecraft:cobblestone",0,"minecraft:stick",0,0,"minecraft:stick",0,}
- pick = {"minecraft:cobblestone","minecraft:cobblestone","minecraft:cobblestone",0,"minecraft:stick",0,0,"minecraft:stick",0,}
- sword = {0,"minecraft:cobblestone",0,0,"minecraft:stick",0,0,"minecraft:stick",0,}
- crafts = {[axe]=axe, [pick]=pick, [sword]=sword}
- function craftsFile()
- if not fs.exists("/crafts") then
- print ("creating crafts file")
- local f = io.open("/crafts", "w")
- f:write(textutils.serialize(crafts))
- f:close()
- end
- end
- function veetaide()
- turtle.select(2)
- repeat
- until turtle.place() ~= false
- end
- function asjadpaika(asjad)
- if asjad == 'tainas' then
- turtle.turnLeft()
- os.sleep(1)
- tools =peripheral.wrap('front')
- tools.pushItemIntoSlot('east',1,1,1)
- tools.pushItemIntoSlot('east',2,1,2)
- end
- end
- function asjad_paigast(asjad)
- turtle.turnLeft()
- if asjad =='tainas' then
- os.sleep(1)
- turtle.select(1)
- turtle.drop()
- turtle.select(2)
- turtle.drop()
- end
- turtle.turnRight()
- end
- canCraft(axe)
- for k,v in pairs(counts) do
- print(k.." = "..v)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement