Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = { ... }
- local outputName = args[1]
- local replaceName = args[2]
- local replaceWith = args[3]
- local outputDirection = args[4]
- local tempDirection = args[5]
- local function turn(direction, inverted)
- if direction == "left" then
- if inverted then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- elseif direction == "right" then
- if inverted then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- end
- local function findFlawed(inventory)
- for i=1, inventory.size() do
- local details = inventory.getItemDetail(i)
- if details ~= nil and details.name == replaceWith then
- return true, i
- end
- end
- return false, nil
- end
- while true do
- local exists, details = turtle.inspect()
- if exists and details.name == outputName then
- break
- end
- turtle.turnLeft()
- end
- for i=1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- turn(outputDirection, true)
- while true do
- if turtle.detect() then
- local _, details = turtle.inspect()
- if details.name == replaceName then
- turtle.dig()
- turn(outputDirection, false)
- turtle.drop()
- turn(outputDirection, true)
- end
- else
- local inout = peripheral.wrap(outputDirection)
- local found, slot = findFlawed(inout)
- if found then
- inout.pushItems(tempDirection, slot, 1, 1)
- turn(tempDirection, false)
- turtle.suck()
- turn(tempDirection, true)
- turtle.place()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement