Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function selectItem(name)
- for i = 1,16,1 do
- local item = turtle.getItemDetail(i)
- if item ~= nil then
- if item["name"] == name then
- turtle.select(i)
- return
- end
- else
- print("no cotton to plant")
- end
- end
- end
- local function harvest()
- planted, block = turtle.inspectDown()
- if planted then
- if block["state"]["age"] == 3 then
- turtle.digDown()
- selectItem("harvestcraft:cottonitem")
- turtle.placeDown()
- end
- else
- selectItem("harvestcraft:cottonitem")
- turtle.placeDown()
- end
- end
- local function row(cols)
- for x = 1,cols-1,1 do
- turtle.forward()
- harvest()
- end
- end
- local function harvestField(width,height)
- turtle.forward()
- harvest()
- for y = 1,(width/2)-1,1 do
- row(height)
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- harvest()
- row(height)
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- harvest()
- end
- row(height)
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- harvest()
- row(height)
- turtle.forward()
- turtle.turnRight()
- for y = 1,width-1,1 do
- turtle.forward()
- end
- --turtle.turnRight()
- end
- local function relocate()
- running = true
- prevOnRail = false
- while running do
- onRail,railType = turtle.inspectUp()
- if onRail then
- if railType["name"] == "minecraft:wooden_slab" then
- if prevOnRail then
- turtle.forward()
- else
- turtle.turnRight()
- end
- end
- if railType["name"] == "minecraft:log" then
- turtle.turnRight()
- turtle.forward()
- end
- if railType["name"] == "minecraft:planks" then
- running = false
- end
- else
- turtle.forward()
- end
- prevOnRail = onRail
- end
- running = true
- while running do
- turtle.turnRight()
- cum,frontBlock = turtle.inspect()
- if frontBlock["name"] == "minecraft:chest" then
- running = false
- turtle.turnRight()
- end
- end
- turtle.turnRight()
- end
- counter = 0
- local X,Y = ...
- relocate()
- print("ready")
- while true do
- sleep(0.5)
- --if redstone.getInput("top") then
- if counter%600==0 then
- while turtle.getFuelLevel() < 400+X*(Y+1) do
- turtle.select(16)
- if turtle.suckDown() == false then
- print("no fuel")
- read()
- end
- turtle.refuel(8)
- turtle.dropDown(64)
- end
- turtle.select(1)
- harvestField(X,Y)
- turtle.turnLeft()
- for cum = 1,16,1 do
- selectItem("harvestcraft:cottonitem")
- turtle.drop(64)
- end
- turtle.select(1)
- turtle.suck()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- print(counter)
- counter = counter + 1
- end
Add Comment
Please, Sign In to add comment