Update 'Turtle/Wheat.lua'

This commit is contained in:
manuel 2023-01-10 08:38:56 +00:00
parent 003797f14e
commit 7d298421e6

View File

@ -106,7 +106,11 @@ function Wheat:resolveTarget(target)
return target
end
function Wheat:createMatrix()
function Wheat:createMatrix(goBack)
if (goBack == nil) then goBack = true end
if(goBack == true) then
goBack = {self.x, self.y, self.z, self.dir}
end
self:moveTo("firstCrop")
self.cropMatrix = {}
for i = 1, self.width do
@ -137,6 +141,10 @@ function Wheat:createMatrix()
end
end
self.x, self.y, self.z = gps.locate()
if (goBack ~= false) then
self:log("moving to goBack")
self:moveTo(goBack)
end
end
function Wheat:clearInv(goBack)
@ -308,4 +316,25 @@ function Wheat:harvestAll(goBack)
self:moveTo(goBack)
end
end
function Wheat:getMatrixString()
local s = self:arrayToString(self.cropMatrix)
return s
end
function Wheat:arrayToString(a)
local s = "{"
for i, v in ipairs(a) do
if(type(v) == "table") then
s = s .. self:arrayToString(v)
else
s = s .. tostring(v)
end
if(i < #a) then
s = s .. ","
end
end
s = s .. "}"
return s
end