Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LENGTH = 8
- -- for harvesting from a square cactus farm
- -- turtle should be on top of a corner cactus, on "left" edge of square, facing the inside of the square
- function checkFuel()
- if turtle.getFuelLevel() < (LENGTH * LENGTH) then -- basic check, not precise
- shell.run("refuel")
- end
- end
- function seesCactus()
- not_air, block = turtle.inspectDown()
- if not_air then
- if block.name == "minecraft:cactus" then
- return true
- end
- end
- return false
- end
- function selectItem(query)
- for slot = 1, 16, 1 do
- turtle.select(slot)
- if turtle.getItemDetail() then
- if turtle.getItemDetail().name == query then
- return true
- end
- if slot == 16 then
- return false
- end
- end
- end
- end
- function breakCactus()
- turtle.digDown()
- turtle.down()
- turtle.digDown()
- turtle.up()
- end
- function turnSwitch(t)
- if t % 2 == 0 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- function homeFromEnd()
- turtle.turnRight()
- for k = 1, LENGTH - 1, 1 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- function dropNoFuel()
- item = turtle.getItemDetail()
- if item then
- if item.name ~= "minecraft:coal" then
- turtle.dropDown()
- end
- end
- end
- function dumpInventory()
- turtle.back()
- turtle.back()
- for k = 1, 16, 1 do
- turtle.select(k)
- dropNoFuel()
- end
- turtle.forward()
- turtle.forward()
- end
- -------------------------------------------------------------
- for i = 1, LENGTH, 1 do
- checkFuel()
- for j = 1, LENGTH, 1 do
- if seesCactus() == true then
- breakCactus()
- end
- if j < LENGTH then
- turtle.forward()
- end
- end
- if i < LENGTH then
- turnSwitch(i)
- turtle.forward()
- turnSwitch(i)
- else
- homeFromEnd()
- dumpInventory()
- end
- end
- -- enderlein
Add Comment
Please, Sign In to add comment