Update 'Turtle/Wheat.lua'

This commit is contained in:
manuel 2023-01-09 20:47:13 +00:00
parent 3deb47d62b
commit 629c747d89

View File

@ -207,7 +207,12 @@ function Wheat:calculateSeeds()
return seeds
end
function Wheat:plantAll()
function Wheat:plantAll(goBack)
if (goBack == nil) then goBack = true end
if(goBack == true) then
goBack = {self.x, self.y, self.z, self.dir}
end
self:fillSeeds("firstCrop")
for i = 1, self.width do
local line = self.cropMatrix[i]
@ -246,4 +251,60 @@ function Wheat:plantAll()
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:harvestAll(goBack)
if (goBack == nil) then goBack = true end
if(goBack == true) then
goBack = {self.x, self.y, self.z, self.dir}
end
self:clearInv("seedChest")
turtle.select(1)
turtle.suckDown()
for i = 1, self.width do
local line = self.cropMatrix[i]
if(i % 2 == 0) then
line = self:reverseArray(line)
end
for j = 1, self.length do
if(line[j] >= 0) then
line[j] = self:getStatusDown()
end
if(line[j] == 7) then
turtle.digDown()
turtle.placeDown()
end
if(j < self.length) then
digForward()
end
end
if(i % 2 == 0) then
self.cropMatrix[i] = self:reverseArray(line)
else
self.cropMatrix[i] = line
end
if(i < self.width) then
if(i % 2 == 0) then
turtle.turnRight()
digForward()
turtle.turnRight()
self.dir = (self.dir + 2) % 4
else
turtle.turnLeft()
digForward()
turtle.turnLeft()
self.dir = (self.dir + 2) % 4
end
end
end
self.x, self.y, self.z = gps.locate()
if (goBack ~= false) then
self:log("moving to goBack")
self:moveTo(goBack)
end
end