Advertisement
forzakenus

Untitled

Nov 27th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.49 KB | None | 0 0
  1. -- Packages lootbags--
  2. function main()
  3.         chest = peripheral.wrap('front')
  4.         chest_size = chest.getInventorySize()
  5.         uncommon_lootbag_count = 0
  6.         common_lootbag_count = 0
  7.         rare_lootbag_count = 0
  8.         epic_lootbag_count= 0
  9.         bags = {}
  10.         bags['uncommon']={}
  11.         bags['uncommon']['asukoht']={}
  12.         bags['common']={}
  13.         bags['common']['asukoht']={}
  14.         bags['rare']={}
  15.         bags['rare']['asukoht']={}
  16.         bags['epic']={}
  17.         bags['epic']['asukoht']={}
  18.         for i=1, chest_size do
  19.             if chest.getStackInSlot(i) ~=nil then
  20.                 if chest.getStackInSlot(i).raw_name=='name.lootbags_lootbaguncommon' then
  21.                     uncommon_lootbag_count = uncommon_lootbag_count+1
  22.                     table.insert(bags['uncommon']['asukoht'],i)
  23.                 elseif chest.getStackInSlot(i).raw_name=='name.lootbags_lootbagcommon' then
  24.                     common_lootbag_count = common_lootbag_count+1
  25.                     table.insert(bags['common']['asukoht'],i)                
  26.                 elseif chest.getStackInSlot(i).raw_name=='name.lootbags_lootbagrare' then
  27.                     rare_lootbag_count = rare_lootbag_count+1
  28.                     table.insert(bags['rare']['asukoht'],i)                
  29.                 elseif chest.getStackInSlot(i).raw_name=='name.lootbags_lootbagepic' then
  30.                     epic_lootbag_count = epic_lootbag_count+1
  31.                     table.insert(bags['epic']['asukoht'],i)            
  32.                 elseif chest.getStackInSlot(i).raw_name=='name.lootbags_lootbaglegendary' then
  33.                     chest.pushItemIntoSlot('west',i,1,1)
  34.                     turtle.select(1)
  35.                     turtle.dropUp()
  36.                     turtle.select(16)
  37.                     os.sleep(1)
  38.                 end
  39.             end
  40.             if uncommon_lootbag_count==4 then
  41.                 tyyp = 'uncommon'
  42.                 if bags['uncommon']~=nil and bags['uncommon']['asukoht']~=nil then
  43.                     packer(bags,chest,tyyp)
  44.                     os.sleep(1)
  45.                     uncommon_lootbag_count = 0
  46.                 end
  47.             elseif common_lootbag_count==4 then
  48.                 tyyp = 'common'
  49.                 if bags['common']~=nil and bags['common']['asukoht']~=nil then
  50.                     packer(bags,chest,tyyp)
  51.                     os.sleep(1)
  52.                     common_lootbag_count =0
  53.                 end
  54.             elseif rare_lootbag_count==4 then
  55.                 tyyp = 'rare'
  56.                 if bags['rare']~=nil and bags['rare']['asukoht']~=nil then
  57.                     packer(bags,chest,tyyp)
  58.                     os.sleep(1)
  59.                     rare_lootbag_count=0
  60.                 end
  61.             elseif epic_lootbag_count==4 then
  62.                 tyyp = 'epic'
  63.                 if bags['epic']~=nil and bags['epic']['asukoht']~=nil then
  64.                     packer(bags,chest,tyyp)
  65.                     os.sleep(1)
  66.                     epic_lootbag_count=0
  67.                 end
  68.             end
  69.         end
  70. end
  71. function packer(bags,chest,tyyp)
  72.         if bags[tostring(tyyp)]~=nil then
  73.         chest.pushItemIntoSlot('west',bags[tyyp]['asukoht'][1],1,1)
  74.         chest.pushItemIntoSlot('west',bags[tyyp]['asukoht'][2],1,2)
  75.         chest.pushItemIntoSlot('west',bags[tyyp]['asukoht'][3],1,5)
  76.         chest.pushItemIntoSlot('west',bags[tyyp]['asukoht'][4],1,6)  
  77.         turtle.select(16)
  78.         turtle.craft()
  79.         turtle.drop()
  80.         end
  81. end
  82. while true do
  83. main()
  84.     print('Pakime kotte kokku')
  85. os.sleep(5)
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement