Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Packages lootbags--
- function main()
- chest = peripheral.wrap('front')
- chest_size = chest.getInventorySize()
- uncommon_lootbag_count = 0
- common_lootbag_count = 0
- rare_lootbag_count = 0
- epic_lootbag_count= 0
- bags = {}
- bags['uncommon']={}
- bags['uncommon']['asukoht']={}
- bags['common']={}
- bags['common']['asukoht']={}
- bags['rare']={}
- bags['rare']['asukoht']={}
- bags['epic']={}
- bags['epic']['asukoht']={}
- for i=1, chest_size do
- if chest.getStackInSlot(i) ~=nil then
- if chest.getStackInSlot(i).raw_name=='name.lootbags_lootbaguncommon' then
- uncommon_lootbag_count = uncommon_lootbag_count+1
- table.insert(bags['uncommon']['asukoht'],i)
- elseif chest.getStackInSlot(i).raw_name=='name.lootbags_lootbagcommon' then
- common_lootbag_count = common_lootbag_count+1
- table.insert(bags['common']['asukoht'],i)
- elseif chest.getStackInSlot(i).raw_name=='name.lootbags_lootbagrare' then
- rare_lootbag_count = rare_lootbag_count+1
- table.insert(bags['rare']['asukoht'],i)
- elseif chest.getStackInSlot(i).raw_name=='name.lootbags_lootbagepic' then
- epic_lootbag_count = epic_lootbag_count+1
- table.insert(bags['epic']['asukoht'],i)
- elseif chest.getStackInSlot(i).raw_name=='name.lootbags_lootbaglegendary' then
- chest.pushItemIntoSlot('west',i,1,1)
- turtle.select(1)
- turtle.dropUp()
- turtle.select(16)
- os.sleep(1)
- end
- end
- if uncommon_lootbag_count==4 then
- tyyp = 'uncommon'
- if bags['uncommon']~=nil and bags['uncommon']['asukoht']~=nil then
- packer(bags,chest,tyyp)
- os.sleep(1)
- uncommon_lootbag_count = 0
- end
- elseif common_lootbag_count==4 then
- tyyp = 'common'
- if bags['common']~=nil and bags['common']['asukoht']~=nil then
- packer(bags,chest,tyyp)
- os.sleep(1)
- common_lootbag_count =0
- end
- elseif rare_lootbag_count==4 then
- tyyp = 'rare'
- if bags['rare']~=nil and bags['rare']['asukoht']~=nil then
- packer(bags,chest,tyyp)
- os.sleep(1)
- rare_lootbag_count=0
- end
- elseif epic_lootbag_count==4 then
- tyyp = 'epic'
- if bags['epic']~=nil and bags['epic']['asukoht']~=nil then
- packer(bags,chest,tyyp)
- os.sleep(1)
- epic_lootbag_count=0
- end
- end
- end
- end
- function packer(bags,chest,tyyp)
- if bags[tostring(tyyp)]~=nil then
- chest.pushItemIntoSlot('west',bags[tyyp]['asukoht'][1],1,1)
- chest.pushItemIntoSlot('west',bags[tyyp]['asukoht'][2],1,2)
- chest.pushItemIntoSlot('west',bags[tyyp]['asukoht'][3],1,5)
- chest.pushItemIntoSlot('west',bags[tyyp]['asukoht'][4],1,6)
- turtle.select(16)
- turtle.craft()
- turtle.drop()
- end
- end
- while true do
- main()
- print('Pakime kotte kokku')
- os.sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement