return true
else
local i, e = find(t)
- if i then return turtle.select(i) end
+ if i then
+ turtle.select(i)
+ return true
+ end
end
return false, "Nothing to select: " .. e
end
-- requires an empty slot to move items around.
-- (this function exists because weak automata cannot digBlock with tools in slots >9)
local transferAndSelect = function(i, t)
- local msg = "Could not transfer and select: "
if i < 1 or i > 16 then return false, msg .. "Index out of range" end
+ -- if a wanted item already is in the wanted slot, select it and return early
+ local item = turtle.getItemDetail(i)
+ if oneOf(t, item.name) then
+ turtle.select(i)
+ return true
+ end
+ local msg = "Could not transfer and select: "
local i_tmp, e = findEmpty()
if not i_tmp then return false, msg .. e end
local i_from, e = find(t)