From 8146ff6a1ad733dde41a46f862d6660aafc6309f Mon Sep 17 00:00:00 2001 From: Olav Bakke Svendsen Date: Tue, 14 May 2024 14:34:25 +0200 Subject: [PATCH] vines/turtle.lua: command strings testing 6 --- vines/turtle.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vines/turtle.lua b/vines/turtle.lua index c3405bd..1a1201a 100644 --- a/vines/turtle.lua +++ b/vines/turtle.lua @@ -81,7 +81,10 @@ local select = function(t) 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 @@ -91,8 +94,14 @@ 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) -- 2.30.2