From: Olav Bakke Svendsen Date: Tue, 14 May 2024 12:34:25 +0000 (+0200) Subject: vines/turtle.lua: command strings testing 6 X-Git-Tag: skystone~13 X-Git-Url: http://git.olavbs.no/?a=commitdiff_plain;h=8146ff6a1ad733dde41a46f862d6660aafc6309f;p=cc.git vines/turtle.lua: command strings testing 6 --- 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)