Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- if #tArgs < 1 then
- print("Rong usage.")
- print("Syntax: cutWood <number of trees to iterate through>")
- return
- end
- local iterations = tonumber(tArgs[1])
- local Vpos = 0
- local function left()
- turtle.turnLeft()
- end
- local function right()
- turtle.turnRight()
- end
- local function up()
- turtle.up()
- end
- local function down()
- turtle.down()
- end
- local function forward()
- turtle.forward()
- end
- local function back()
- turtle.back()
- end
- local function returnToGroundPosition()
- while Vpos > 0 do
- if not turtle.down() then
- print("Tried to go down further and couldn't.")
- end
- Vpos = Vpos - 1
- end
- end
- local function placeSapling()
- end
- local function plantSaplings()
- turtle.select(1)
- forward()
- forward()
- left()
- -- Sapling 01
- if not turtle.place() then
- return false
- end
- left()
- forward()
- right()
- -- Sapling 02
- if not turtle.place() then
- return false
- end
- right()
- -- Sapling 03
- if not turtle.place() then
- return false
- end
- back()
- -- Sapling 04
- if not turtle.place() then
- return false
- end
- end
- local function applyBoneMeal()
- turtle.select(1) -- Sapling
- while turtle.compare(1) do
- turtle.select(2) -- Bone Meal
- if not turtle.place() then
- return false
- end
- turtle.select(1) -- Sapling
- end
- end
- local function clearFirstLayer()
- turtle.dig()
- forward()
- turtle.dig()
- forward()
- left()
- turtle.dig()
- forward()
- left()
- turtle.dig()
- forward()
- left()
- forward()
- left()
- end
- local function clearNextLayer()
- turtle.digUp()
- turtle.up()
- Vpos = Vpos + 1
- turtle.dig()
- forward()
- left()
- turtle.dig()
- forward()
- left()
- turtle.dig()
- forward()
- left()
- forward()
- left()
- end
- local function cutTree()
- clearFirstLayer()
- while turtle.detectUp() do
- clearNextLayer()
- end
- -- fuel = turtle.getFuelLevel()
- -- if fuel < 1 then
- -- while not turtle.refuel() do
- -- print ("Waiting for fuel...")
- -- end
- -- end
- -- if not turtle.dig() then
- -- print("Something's wrong! No tree to cut. Aborting")
- -- return
- -- end
- returnToGroundPosition()
- end
- local function returnWood()
- right()
- right()
- forward()
- for n=3,16 do
- turtle.select(n)
- turtle.drop()
- end
- left()
- left()
- end
- for i = 1, iterations do
- plantSaplings()
- applyBoneMeal()
- cutTree()
- returnWood()
- end
Advertisement
Add Comment
Please, Sign In to add comment