added farming builds
This commit is contained in:
@ -129,3 +129,68 @@ function build_room(length, width, height)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- sweepField() moves acress the rows
|
||||
-- and columns of an area in front and
|
||||
-- to the right of the turtle, calling
|
||||
-- the provided sweepFunc at each space
|
||||
function sweepField(length, width, sweepFunc)
|
||||
local turnRightNext = true
|
||||
|
||||
for x = 1, width do
|
||||
for y = 1, length do
|
||||
sweepFunc()
|
||||
|
||||
-- don't move forward on the last row
|
||||
if y ~= width then
|
||||
turtle.forward()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- don't turn on the last column
|
||||
if x ~= width then
|
||||
-- turn to the next column
|
||||
if turnRightNext then
|
||||
turtle.turnRight()
|
||||
turtle.forward()
|
||||
turtle.turnRight()
|
||||
else
|
||||
turtle.turnLeft()
|
||||
turtle.forward()
|
||||
turtle.turnLeft()
|
||||
end
|
||||
|
||||
turnRightNext = not turnRightNext
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- move back to the start position
|
||||
if width % 2 == 0 then
|
||||
turtle.turnRight()
|
||||
else
|
||||
for y = 1, length -1 do
|
||||
turtle.back()
|
||||
end
|
||||
turtle.turnLeft()
|
||||
end
|
||||
turtle.turnRight()
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--findBlock() spins around searching
|
||||
--for the named block next to the turtle
|
||||
function findBlock(name)
|
||||
local result, block
|
||||
|
||||
for i = 1, 4 do
|
||||
result, block = turtle.inspect()
|
||||
if block ~= nil and block['name'] == name then
|
||||
return true
|
||||
end
|
||||
turtle.turnRight()
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
Reference in New Issue
Block a user