Advertisement
Wassaa

Vellington

Nov 26th, 2016
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. p = peripheral.wrap("right")
  2. t = peripheral.wrap("top")
  3.  
  4. suund = 'west'
  5. inv_size = p.getInventorySize()
  6. location={}
  7. function Main()
  8. end
  9.    
  10. function jahu()
  11.     for i=1, inv_size do
  12.         if p.getStackInSlot(i) ~=nil then
  13.           if p.getStackInSlot(i)['id'] == 'harvestcraft:saltItem' then
  14.            location['sool']={}
  15.            location['sool']['asukoht']=i
  16.            location['sool']['kogus']=p.getStackInSlot(i).qty
  17.           elseif p.getStackInSlot(i)['id'] == 'Natura:barleyFood' or p.getStackInSlot(i)['id'] == 'EnderIO:itemPowderIngot' then
  18.            location['jahu']={}
  19.            location['jahu']['asukoht']=i
  20.            location['jahu']['kogus']=p.getStackInSlot(i).qty
  21.           end
  22.         end
  23.     end
  24.     if (location['sool']~=nil  and location['jahu']~=nil) then
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement