Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local storageBlocks = {
- "minecraft:chest",
- "minecraft:trapped_chest",
- "minecraft:barrel",
- "minecraft:shulker_box",
- "minecraft:white_shulker_box",
- "minecraft:orange_shulker_box",
- "minecraft:magenta_shulker_box",
- "minecraft:light_blue_shulker_box",
- "minecraft:yellow_shulker_box",
- "minecraft:lime_shulker_box",
- "minecraft:pink_shulker_box",
- "minecraft:gray_shulker_box",
- "minecraft:light_gray_shulker_box",
- "minecraft:cyan_shulker_box",
- "minecraft:purple_shulker_box",
- "minecraft:blue_shulker_box",
- "minecraft:brown_shulker_box",
- "minecraft:green_shulker_box",
- "minecraft:red_shulker_box",
- "minecraft:black_shulker_box",
- "minecraft:hopper"
- }
- function checkList(list, thing)
- for _, str in ipairs(list) do
- if thing == str then
- return true
- end
- end
- return false
- end
- function stackLimit()
- if turtle.getItemCount() ~= 0 then
- return turtle.getItemCount() + turtle.getItemSpace()
- end
- return 0
- end
- function itemSuckUp()
- local success = turtle.suckUp()
- if not success then
- return nil
- end
- local item = turtle.getItemDetail()
- if item then
- return item.name, turtle.getItemCount()
- else
- return nil
- end
- end
- function countCheck(count)
- local itemCount = 0
- for slot = 1, 16 do
- turtle.select(slot)
- local itemQty = turtle.getItemCount()
- if itemQty > 0 then
- itemCount = itemCount + itemQty
- end
- end
- return itemCount
- end
- function takeAll()
- if turtle.detect() then
- local success, data = turtle.inspect()
- if success then
- if checkList(storageBlocks, data.name) then
- print("There is a chest in front of the turtle")
- local slotsToFill = 16
- for slot = 1, slotsToFill do
- if turtle.getItemCount(slot) == 0 then
- if turtle.suck(slot) then
- print("Took items from slot " .. slot)
- else
- print("Error")
- end
- end
- end
- turtle.select(1)
- else
- print("There is a block, but it's not a chest")
- end
- else
- print("Failed to inspect")
- end
- else
- print("There's nothing in front of the turtle")
- end
- end
- function takeAllUp()
- if turtle.detect() then
- local success, data = turtle.inspect()
- if success then
- if checkList(storageBlocks, data.name) then
- print("There is a chest in front of the turtle")
- local slotsToFill = 16 -- Number of slots to attempt to fill
- for slot = 1, slotsToFill do
- if turtle.getItemCount(slot) == 0 then
- if turtle.suckUp(slot) then
- print("Took items from slot " .. slot)
- else
- print("Error")
- end
- end
- end
- turtle.select(1)
- else
- print("There is a block, but it's not a chest")
- end
- else
- print("Failed to inspect")
- end
- else
- print("There's nothing in front of the turtle")
- end
- end
- function takeAllDown()
- if turtle.detect() then
- local success, data = turtle.inspect()
- if success then
- if checkList(storageBlocks, data.name) then
- print("There is a chest in front of the turtle")
- local slotsToFill = 16
- for slot = 1, slotsToFill do
- if turtle.getItemCount(slot) == 0 then
- if turtle.suckDown(slot) then
- print("Took items from slot " .. slot)
- else
- print("Error")
- end
- end
- end
- turtle.select(1)
- else
- print("There is a block, but it's not a chest")
- end
- else
- print("Failed to inspect")
- end
- else
- print("There's nothing in front of the turtle")
- end
- end
- function insertSome(start)
- if turtle.detect() then
- local success, data = turtle.inspect()
- if success then
- if checkList(storageBlocks, data.name) then
- print("There is a chest in front of the turtle")
- for slot = start, 16 do
- if slot ~= 1 and turtle.getItemCount(slot) > 0 then
- turtle.select(slot)
- turtle.drop()
- print("Deposited items from slot " .. slot)
- end
- end
- turtle.select(1)
- else
- print("There is a block, but it's not a chest")
- end
- else
- print("Failed to inspect")
- end
- else
- print("There's nothing in front of the turtle")
- end
- end
- function insertAll()
- if turtle.detect() then
- local success, data = turtle.inspect()
- if success then
- if checkList(storageBlocks, data.name) then
- print("There is a chest in front of the turtle")
- for slot = 1, 16 do
- if turtle.getItemCount(slot) > 0 then
- turtle.select(slot)
- turtle.drop()
- print("Deposited items from slot " .. slot)
- end
- end
- turtle.select(1)
- else
- print("There is a block, but it's not a chest")
- return false
- end
- else
- print("Failed to inspect")
- return false
- end
- else
- print("There's nothing in front of the turtle")
- return false
- end
- end
- function insertAllUp()
- if turtle.detect() then
- local success, data = turtle.inspectUp()
- if success then
- if checkList(storageBlocks, data.name)then
- print("There is a chest in front of the turtle")
- for slot = 1, 16 do
- if turtle.getItemCount(slot) > 0 then
- turtle.select(slot)
- if turtle.dropUp() then
- condition = true
- else
- condition = false
- break
- end
- print("Deposited items from slot " .. slot)
- end
- end
- turtle.select(1)
- else
- print("There is a block, but it's not a chest")
- end
- else
- print("Failed to inspect")
- end
- else
- print("There's nothing in front of the turtle")
- end
- return condition
- end
- -- takes a starting slot to deposit from. Using 1 deposits the entire inventory, 2 starts from slot 2 onwards
- function insertAllDown()
- condition = 0
- if turtle.detect() then
- local success, data = turtle.inspectDown()
- if success then
- if checkList(storageBlocks, data.name) then
- print("There is a chest in front of the turtle")
- for slot = 1, 16 do
- if turtle.getItemCount(slot) > 0 then
- turtle.select(slot)
- if turtle.dropDown() then
- condition = 1
- else
- condition = 2
- end
- print("Deposited items from slot " .. slot)
- end
- end
- turtle.select(1)
- else
- print("There is a block, but it's not a chest")
- end
- else
- print("Failed to inspect")
- end
- else
- print("There's nothing in front of the turtle")
- end
- return condition
- end
Add Comment
Please, Sign In to add comment