Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- assert(loadfile("utils"))()
- local custom_items = {
- cobblestone = "minecraft:cobblestone",
- dirt = "minecraft:dirt",
- lava_bucket = "minecraft:lava_bucket",
- bucket = "minecraft:bucket"
- }
- local dropDirections = {
- [custom_items.cobblestone] = {turns = 1, direction = 'right', dropAction = turtle.drop},
- [custom_items.dirt] = {turns = 2, direction = 'left', dropAction = turtle.drop},
- [custom_items.lava_bucket] = {dropAction = turtle.dropUp}, -- Drop up for lava buckets
- [custom_items.bucket] = {dropAction = turtle.dropUp} -- Drop up for empty buckets
- }
- local function handleDrop(item, slot)
- local direction = dropDirections[item.name]
- if direction then
- if direction.direction then
- local turnFunction = direction.direction == 'right' and turtle.turnRight or turtle.turnLeft
- for i = 1, direction.turns or 0 do
- turnFunction()
- end
- end
- turtle.select(slot)
- do (direction.dropAction or turtle.dropDown)() end
- if direction.direction then
- local turnBackFunction = direction.direction == 'right' and turtle.turnLeft or turtle.turnRight
- for i = 1, direction.turns or 0 do
- turnBackFunction()
- end
- end
- else
- turtle.select(slot)
- turtle.dropDown()
- end
- end
- -- Main run function
- local function main()
- while true do
- while turtle.suckUp() do end -- Continuously suck items from above
- local inventory = getInventory()
- for k, v in pairs(inventory) do
- handleDrop(v, v.slot)
- end
- sleep(1) -- Throttle the loop to prevent excessive resource usage
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement