92 lines
2 KiB
Lua
92 lines
2 KiB
Lua
function plant()
|
|
im = require("inventorymanager")
|
|
mosscount = im.pull("minecraft:moss_block",1)
|
|
mealcount = im.pull("minecraft:bone_meal",2)
|
|
if mosscount <= 1 then
|
|
return false, "not enough moss"
|
|
end
|
|
if mealcount <= 16 then
|
|
return false, "not enough bone meal"
|
|
end
|
|
if turtle.getFuelLevel() < 500 then
|
|
return false, "not enough fuel"
|
|
end
|
|
while turtle.down() do
|
|
height = height+1
|
|
end
|
|
turtle.up()
|
|
for i = 1,4 do
|
|
for j = 1,5 do
|
|
turtle.forward()
|
|
turtle.forward()
|
|
turtle.select(1)
|
|
turtle.placeUp()
|
|
turtle.select(2)
|
|
turtle.placeUp()
|
|
turtle.digUp()
|
|
turtle.forward()
|
|
--turtle.forward()
|
|
end
|
|
if math.mod(i,2) == 1 then
|
|
turtle.turnRight()
|
|
turtle.forward()
|
|
turtle.forward()
|
|
turtle.forward()
|
|
turtle.forward()
|
|
turtle.turnRight()
|
|
else
|
|
turtle.turnLeft()
|
|
turtle.forward()
|
|
turtle.forward()
|
|
turtle.forward()
|
|
turtle.forward()
|
|
turtle.turnLeft()
|
|
end
|
|
end
|
|
turtle.turnLeft()
|
|
for i = 1,16 do
|
|
turtle.forward()
|
|
end
|
|
turtle.turnRight()
|
|
return true
|
|
end
|
|
function clear()
|
|
turtle.digDown()
|
|
turtle.down()
|
|
for i = 1,16 do
|
|
for j = 1,15 do
|
|
turtle.dig()
|
|
turtle.digDown()
|
|
turtle.forward()
|
|
end
|
|
turtle.digDown()
|
|
if math.mod(i,2) == 1 then
|
|
turtle.turnRight()
|
|
turtle.dig()
|
|
turtle.forward()
|
|
turtle.turnRight()
|
|
else
|
|
turtle.turnLeft()
|
|
turtle.dig()
|
|
turtle.forward()
|
|
turtle.turnLeft()
|
|
end
|
|
end
|
|
turtle.turnLeft()
|
|
for i = 1,16 do
|
|
turtle.forward()
|
|
end
|
|
turtle.turnRight()
|
|
return true
|
|
end
|
|
|
|
height = 0
|
|
turtle.forward()
|
|
if plant() then
|
|
clear()
|
|
end
|
|
for i = 1,height do
|
|
turtle.up()
|
|
end
|
|
turtle.back()
|
|
|