Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Berrypicker
- -- 2015-01-24
- ------------------------------------------------------
- -- Farm Setup
- -- top
- -- BB..BB
- -- CEE..ETC
- -- DD..DI
- -- front
- --CBB..BBC
- --CBB..BBC
- --CDD..DIC
- -- C Cobblestone
- -- D dirt
- -- B Bush
- -- I chest
- -- ID string constants
- WOOD = "minecraft:log"
- DIRT = "minecraft:dirt"
- GRASS = "minecraft:grass"
- COBBLE = "minecraft:cobblestone"
- SAPLING = "minecraft:sapling"
- LEAVES = "minecraft:leaves"
- APPLE = "minecraft:sapling"
- BONEMEAL = "minecraft:dye" -- with damage/meta 15
- CHEST = "minecraft:chest"
- function contains(where, what)
- return string.find(string.lower(where), what)
- end
- function safeForward()
- turtle.suck()
- while not turtle.forward() do
- if not turtle.inspect() then
- turtle.dig()
- else
- return false
- end
- end
- turtle.suck()
- return true
- end
- function getInPosition()
- print("Getting in position, looking for chest")
- -- assuming we are not positioned correctly
- local onGround = false
- local atChest = false
- -- get down first
- while not onGround do
- local success, data = turtle.inspectDown()
- if success then
- print("Found: ", data.name)
- if data.name == DIRT or data.name == GRASS then
- print("Must be on on the ground")
- onGround = true
- else
- turtle.digDown()
- turtle.down()
- end
- else
- print("Must be in the air")
- turtle.down()
- end
- end
- -- now find the chest
- while not atChest do
- local success, data = turtle.inspect()
- if success then
- if data.name == COBBLE then
- print("Seeing the stone, turning right")
- turtle.turnRight()
- elseif data.name == DIRT then
- print("Seeing dirt, turning left")
- turtle.turnRight()
- elseif contains(data.name, "bush") then
- print("Seeing the bush, turning right")
- turtle.turnRight()
- elseif contains(data.name, "chest") then
- print("Seeing the chest..")
- print("Position reached")
- atChest = true
- end
- else
- print("Nothing in front, moving")
- safeForward()
- end
- end
- end
- function dropOff()
- for i = 1, 16, 1 do
- turtle.select(i)
- turtle.drop()
- end
- end
- function pickBush()
- turtle.suck()
- turtle.up()
- turtle.suck()
- turtle.up()
- turtle.suck()
- turtle.down()
- turtle.down()
- end
- getInPosition()
- dropOff()
- while true do
- turtle.turnRight()
- while not turtle.inspect() do
- safeForward()
- end
- turtle.turnRight()
- local canMoveRight = true
- while canMoveRight do
- pickBush()
- turtle.turnRight()
- canMoveRight = safeForward()
- turtle.turnLeft()
- end
- turtle.turnRight()
- turtle.turnRight()
- dropOff()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement