Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("flex.lua")
- os.loadAPI("dig.lua")
- local args,auto = {...},false
- if args[1] == "auto" then
- auto = true
- end --if
- dig.setFuelSlot(2,16)
- local function chopTree()
- flex.send("Chopping tree...",colors.orange)
- dig.fwd()
- while dig.gety() < 30 do
- turtle.dig()
- dig.up()
- end
- dig.right()
- dig.fwd()
- dig.left()
- while dig.gety() > 0 do
- dig.down()
- turtle.dig()
- end
- dig.gotox(0)
- dig.gotoz(0)
- dig.gotor(0)
- flex.send("Tree chopped!",colors.lime)
- end --function
- local function plantSaplings()
- local a,x
- turtle.select(1)
- a = true
- while turtle.getItemCount() < 4 or
- string.find(turtle.getItemDetail()
- ["name"],"sapling") == 0 do
- if a then
- flex.send("Insert saplings please!",
- colors.orange)
- a = false
- end
- sleep(1)
- end
- if not a then
- flex.send("Thanks!",colors.lime)
- end
- flex.send("Planting saplings...",colors.orange)
- dig.up()
- dig.fwd()
- turtle.digDown()
- dig.placeDown()
- for x=1,3 do
- dig.fwd()
- turtle.digDown()
- dig.placeDown()
- dig.right()
- end
- dig.fwd()
- dig.left()
- dig.fwd()
- dig.down()
- dig.right(2)
- flex.send("Saplings planted!",colors.lime)
- end --function
- local grow = false
- local function treeGrows()
- while string.find(flex.getBlock(),
- "log") == nil do
- sleep(2)
- if turtle.getItemCount(1) < 64 then
- flex.condense()
- end --if
- end --while
- grow = true
- end --function
- if fs.exists("startup.lua") then
- dig.loadCoords()
- if dig.getx() ~= 0 or
- dig.gety() ~= 0 or
- dig.getz() ~= 0 or
- dig.getr() ~= 0 then
- dig.goto(0,0,0,0)
- chopTree()
- end --if
- end --if
- if auto then
- dig.makeStartup("tree",args)
- local done = false
- while not done do
- turtle.select(1)
- plantSaplings()
- flex.condense()
- dig.left(2)
- flex.dump(3,16)
- dig.left(2)
- flex.send("Waiting for tree to grow..."
- ,colors.lightBlue)
- grow = false
- parallel.waitForAny(treeGrows,
- flex.keyPress)
- if grow then
- chopTree()
- else
- done = true
- end --if/else
- end --while
- else
- if string.find(flex.getBlock(),
- "log") ~= nil then
- chopTree()
- else
- flex.send("No tree found",colors.orange)
- end
- end --if/else
- os.unloadAPI("dig.lua")
- os.unloadAPI("flex.lua")
- if fs.exists("startup.lua") then
- shell.run("rm startup.lua")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement