Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Chop v.2.0 by DumperJumper(dumperjumper.com) from 09.02.16
- -- Turtle expects a Chest behind it to put wood in and
- -- a chest on the right for Saplings
- --
- -- Layout:
- -- SS S=Sapling
- -- SS T=Turtle
- -- TC C=Chest
- -- C
- local checkInterval = 20 -- Seconds the Turtle waits before next check if a Tree has grown
- local height = 0 -- Needed in Runtime
- local tree = true -- Needed in Runtime
- local wait = 0 -- Needed in Runtime
- local function refuel()
- if turtle.getFuelLevel() < 100 then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- --MOVEMENT-FUNCTIONS
- local function forward()
- refuel()
- turtle.forward()
- end
- local function back()
- refuel()
- turtle.back()
- end
- local function down()
- refuel()
- if turtle.detectDown() then
- turtle.digDown()
- end
- turtle.down()
- height = height - 1
- end
- local function up()
- refuel()
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.up()
- height = height + 1
- end
- --MOVEMENT-END
- local function plantSapling()
- if turtle.getItemCount(2) < 1 then
- print("Could not replant Tree, Sapling in Slot 2 are missing")
- else
- turtle.select(2)
- turtle.place()
- end
- end
- local function replant()
- plantSapling()
- turtle.turnLeft()
- back()
- plantSapling()
- turtle.turnRight()
- plantSapling()
- back()
- plantSapling()
- end
- local function manageItems()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=3, 16 do
- turtle.select(i)
- if not turtle.compareTo(2) then
- turtle.drop()
- end
- end
- turtle.turnLeft()
- for i=3, 16 do
- turtle.select(i)
- turtle.drop()
- end
- while turtle.getItemCount(2) < 8 do
- turtle.select(2)
- if not turtle.suck() then
- print("NOOOO!!! NO MOAR SAPLINGS! *killed himself*")
- turtle.turnLeft()
- os.shutdown()
- end
- end
- turtle.turnLeft()
- end
- while true do
- while tree do
- turtle.dig()
- if height == 0 then forward() end
- turtle.dig()
- tree = turtle.detectUp()
- up()
- end
- turtle.turnLeft()
- forward()
- turtle.turnRight()
- while height > 0 do
- down()
- turtle.dig()
- end
- print("Done felling Tree")
- print("Replanting...")
- replant()
- manageItems()
- print("Waiting for new Tree to grow...")
- while not tree do
- os.sleep(checkInterval)
- up()
- tree = turtle.detect()
- down()
- wait = wait + 1
- end
- print("WOAH new Tree! That took " .. wait*checkInterval .. " seconds!")
- height = 0
- wait = 0
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement