From d8c433c6b2618c1b66fe6b1ee74518e095bd7d51 Mon Sep 17 00:00:00 2001 From: Olav Bakke Svendsen Date: Tue, 14 May 2024 13:24:55 +0200 Subject: [PATCH] vines/turtle.lua: command strings testing 3 --- vines/turtle.lua | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/vines/turtle.lua b/vines/turtle.lua index 0cbe390..4df09c6 100644 --- a/vines/turtle.lua +++ b/vines/turtle.lua @@ -119,7 +119,7 @@ end local harvest = function() local facing_block, block = turtle.inspect() if not (facing_block and block.name == "minecraft:vine") then return false, "Not facing vine" end - if not select(shears) then return false, "No shears available" end + if not transferAndSelect(shears) then return false, "No shears available" end local cut, cut_error = automata.digBlock() if not cut then return false, "Could not cut vine: " .. cut_error end local collect, collect_error = automata.collectItems() @@ -156,16 +156,34 @@ runCommand = function(str) -- print(cmd, tostring(i).."/"..tostring(n)) -- end return runCommand(rest) +end + +-- rep : number of repeats -> string -> string | nil +-- repeats string n times +-- +local = function(n, str) + if not n or n < 0 then return nil end + local s = "" + for i 1, i do + s = s .. str + end end - + -- for testing purposes local sequence = function() print("pretending to unload stray items") print("pretending to refuel") print("pretending to stock up on shears") - local cmd = "rf3hfhflfr2" + local enter_vineyard = "rf3hfhflfr2" + local harvest_north = + "d2h u4h" + .. rep(6,"u2h") .. "lfdrh" + .. rep(7,"d2h") .. "lfurh" + .. rep(7,"u2h") .. "lfdrh" + .. rep(7,"d2h") .. "lfurh" + .. rep(7,"u2h") .. "lfdrh" print(cmd) - return runCommand(cmd) + return runCommand(cmd..) end while true do -- 2.30.2