Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("== Tree farming script ===")
- print("Author: MichiVIP")
- print("Version: 0.0.1")
- local rubberwoodstr = "IC2:rubberWood"
- local grassstr = "minecraft:grass"
- local dirtstr = "minecraft:dirt"
- local detectionstr = "eng_toolbox:limestone"
- local cheststr = "minecraft:chest"
- local waterstr = "minecraft:flowing_water"
- write("Enter sleep amount in seconds: ")
- local sleepamount = tonumber(io.read())
- print("Place saplings in slot 1 and a chest behind the turtle")
- io.read()
- local function farmtree()
- local success, data = turtle.inspect()
- if not success then
- turtle.select(1)
- turtle.place()
- return
- elseif data.name == rubberwoodstr then
- turtle.dig()
- end
- turtle.forward()
- local counter = 0
- while true do
- local success, data = turtle.inspectUp()
- if success and data.name == rubberwoodstr then
- turtle.digUp()
- turtle.up()
- counter = counter + 1
- else
- break
- end
- end
- for i = 0, counter, 1 do
- turtle.down()
- end
- turtle.back()
- if not turtle.detect() then
- local success, data = turtle.inspect()
- if success and data.name == waterstr then
- return
- end
- turtle.select(1)
- turtle.place()
- end
- end
- local function backtomain()
- turtle.down()
- while true do
- turtle.back()
- local success, data = turtle.inspectDown()
- if success and data.name == detectionstr then
- turtle.turnRight()
- return
- end
- end
- end
- local function nexttree()
- if not turtle.forward() then
- return false
- end
- while true do
- local success, data = turtle.inspectDown()
- if success and data.name == detectionstr then
- turtle.turnLeft()
- break
- else
- if not turtle.forward() then
- return false
- end
- end
- end
- while true do
- local success, data = turtle.inspect()
- if success then
- if data.name == dirtstr or data.name == grassstr then
- turtle.up()
- local success, data = turtle.inspect()
- if not success or not data.name == rubberwoodstr then
- turtle.down()
- backtomain()
- return nexttree()
- end
- break
- end
- end
- turtle.forward()
- end
- return true
- end
- local function returntohome()
- turtle.turnRight()
- turtle.turnRight()
- while true do
- turtle.forward()
- local success, data = turtle.inspect()
- if success and data.name == cheststr then
- for i = 2, 16, 1 do
- turtle.select(i)
- print(turtle.drop())
- end
- turtle.turnRight()
- turtle.turnRight()
- return
- end
- end
- end
- local counter = 1
- while true do
- print("Starting tree farming try no " .. counter)
- while nexttree() do
- farmtree()
- backtomain()
- end
- returntohome()
- counter = counter + 1
- os.sleep(sleepamount)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement