Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local inch = peripheral.wrap("front")
- local outch = peripheral.wrap("back")
- local overflow = 28
- local slots = 54
- local block9 = {1, 2, 3, 5, 6, 7, 9, 10, 11}
- local block4 = {1, 2, 5, 6}
- local function craft(chest, pushDir, slot, count, recipe, target)
- print("craft ", pushDir, " ", count, " from ", slot, " to ", target)
- for _, pos in pairs(recipe) do
- chest.pushItem(pushDir, slot, count / #recipe, pos)
- end
- turtle.craft()
- outch.pullItem("north", 1, count / #recipe, target)
- for _, pos in pairs(recipe) do
- for target = overflow, slots do
- count = turtle.getItemCount(pos)
- if count == 0 then
- break
- end
- outch.pullItem("north", pos, count, target)
- end
- end
- end
- local function compress(slot, stack, item, recipe, offset, stride, levels)
- if stack and stack.display_name == item and stack.qty >= #recipe then
- print("comp ", stack.qty, "x ", item, " from ", slot)
- craft(inch, "south", slot, stack.qty, recipe, offset)
- for level = 0, levels - 2 do
- local pos = offset + level * stride
- stack = outch.getStackInSlot(pos)
- if stack and stack.qty >= #recipe then
- craft(outch, "north", pos, stack.qty, recipe, pos + stride)
- end
- end
- end
- end
- local function dropIdPrefix(slot, stack, item, dir)
- if string.sub(stack.id, 1, string.len(item)) == item then
- print("drop ", stack.qty, "x ", stack.id)
- inch.pushItem("south", slot, stack.qty)
- turtle.dropUp()
- end
- end
- turtle.select(1)
- while true do
- inch.condenseItems()
- for slot, stack in pairs(inch.getAllStacks()) do
- stack = stack.all()
- compress(slot, stack, "Cobblestone", block9, 1, 1, 8)
- compress(slot, stack, "Dirt", block9, 10, 1, 8)
- compress(slot, stack, "Gravel", block9, 9, 9, 2)
- compress(slot, stack, "Redstone", block9, 19, 1, 1)
- compress(slot, stack, "Lapis Lazuli", block9, 20, 1, 1)
- compress(slot, stack, "Electrotine", block9, 21, 1, 1)
- compress(slot, stack, "Ruby", block9, 22, 1, 1)
- compress(slot, stack, "Sapphire", block9, 23, 1, 1)
- compress(slot, stack, "Peridot", block9, 24, 1, 1)
- compress(slot, stack, "Diamond", block9, 25, 1, 1)
- compress(slot, stack, "Certus Quartz Crystal", block4, 26, 1, 1)
- compress(slot, stack, "Salt", block9, 27, 1, 1)
- dropIdPrefix(slot, stack, "chisel:")
- dropIdPrefix(slot, stack, "Thaumcraft:")
- dropIdPrefix(slot, stack, "BiomesOPlenty:")
- dropIdPrefix(slot, stack, "Forestry:")
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement