Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Chest1slots_Stone = {}
- local Chest2slots_Wood = {}
- local Chest3slots_Ores = {}
- local Chest4slots_Other = {}
- local ChestPath = {false,false,false,false}
- local x,z = -2,0
- function CheckChest(slot)
- if turtle.getItemCount(slot)>0 then
- local temp= turtle.getItemDetail(slot)
- local SlotItemName = temp.name
- if string.find(SlotItemName,"stone") then
- table.insert(Chest1slots_Stone,slot)
- ChestPath[1] = true
- elseif string.find(SlotItemName,"log") or (string.find(SlotItemName,"planks")) then
- table.insert(Chest2slots_Wood,slot)
- ChestPath[2] = true
- elseif string.find(SlotItemName,"ore") then
- table.insert(Chest3slots_Ores,slot)
- ChestPath[3] = true
- else
- table.insert(Chest4slots_Other,slot)
- ChestPath[4] = true
- end
- end
- end
- function blockpickup()
- local i = 1
- repeat
- turtle.suckDown()
- i = i + 1
- turtle.select(i)
- until i == 16
- turtle.select(1)
- end
- function go_to(chestnum)
- if chestnum == 0 then
- repeat
- turtle.back()
- x = x - 1
- until x == -2
- else
- if x < chestnum then
- for i = 1,chestnum-x do
- turtle.forward()
- x = x + 1
- end
- else
- if x > chestnum then
- for i = 1,x-chestnum do
- turtle.back()
- x = x - 1
- end
- end
- end
- end
- end
- function turnINTOchest()
- turtle.turnLeft()
- turtle.forward()
- end
- function turnOUTFROMchest()
- turtle.back()
- turtle.turnRight()
- end
- function PlaceItemsInChest(chestnum)
- go_to(chestnum)
- turnINTOchest()
- if chestnum == 1 then
- for i = 1,#Chest1slots_Stone do
- turtle.select(Chest1slots_Stone[i])
- turtle.dropDown()
- end
- elseif chestnum == 2 then
- for i = 1,#Chest2slots_Wood do
- turtle.select(Chest2slots_Wood[i])
- turtle.dropDown()
- end
- elseif chestnum == 3 then
- for i = 1 ,#Chest3slots_Ores do
- turtle.select(Chest3slots_Ores[i])
- turtle.dropDown()
- end
- elseif chestnum == 4 then
- for i = 1 ,#Chest4slots_Other do
- turtle.select(Chest4slots_Other[i])
- turtle.dropDown()
- end
- end
- turnOUTFROMchest()
- end
- blockpickup()
- local slot = 1
- repeat
- CheckChest(slot)
- slot = slot + 1
- until slot == 16
- for i = 1 ,4 do
- if ChestPath[i] then
- PlaceItemsInChest(i)
- end
- end
- turtle.select(1)
- go_to(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement