Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ignore={["minecraft:grass"] = true,["minecraft:dirt"] = true,["minecraft:stone"] = true,["minecraft:cobblestone"] = true,["minecraft:gravel"] = true,["minecraft:sand"] = true}
- wood={["MineFactoryReloaded:rubberwood.log"] = true,["minecraft:log"] = true,["Natura:Rare Tree"] = true}
- height = 0
- direction = 1
- top = 0
- --Move Functions--
- function tl()
- turtle.turnLeft()
- end
- function tr()
- turtle.turnRight()
- end
- function tf()
- while not turtle.forward() do
- turtle.attack()
- end
- end
- function td()
- while not turtle.down() do
- turtle.attackDown()
- end
- end
- function tu()
- while not turtle.up() do
- turtle.attackUp()
- end
- end
- --Block Inspect Functions--
- function checkWood()
- success,data=turtle.inspect()
- if wood[data.name] then
- return true
- else
- return false
- end
- end
- function checkWoodDown()
- success,data=turtle.inspectDown()
- if wood[data.name] then
- return true
- else
- return false
- end
- end
- function checkWoodUp()
- success,data=turtle.inspectUp()
- if wood[data.name] then
- return true
- else
- return false
- end
- end
- function checkIgnoreDown()
- success,data=turtle.inspectDown()
- if ignore[data.name] then
- return true
- else
- return false
- end
- end
- function checkIgnore()
- success,data=turtle.inspect()
- if ignore[data.name] then
- return true
- else
- return false
- end
- end
- --Branch Cutting--
- function jc()
- if checkWoodUp() == true then
- turtle.digUp()
- end
- if checkWoodDown() == true then
- turtle.digDown()
- end
- end
- function cutBranch1()
- jc()
- dc()
- tf()
- jc()
- tr()
- dc()
- tf()
- jc()
- tl()
- for i = 1, 2 do
- dc()
- tf()
- jc()
- end
- jc()
- tl()
- dc()
- tf()
- jc()
- tl()
- for i = 1, 2 do
- dc()
- tf()
- jc()
- end
- jc()
- tr()
- dc()
- tf()
- jc()
- tr()
- for i = 1,2 do
- dc()
- tf()
- jc()
- end
- tr()
- tf()
- tr()
- for i = 1, 3 do
- tf()
- end
- tl()
- end
- function cutBranchC()
- for i = 1, 2 do
- dc()
- tf()
- jc()
- end
- tl()
- dc()
- tf()
- jc()
- tl()
- for i = 1, 2 do
- dc()
- tf()
- jc()
- end
- tr()
- dc()
- tf()
- jc()
- tr()
- for i = 1, 2 do
- dc()
- tf()
- jc()
- end
- tr()
- tf()
- tf()
- tr()
- tf()
- tf()
- tl()
- end
- function dc()
- if checkWoodDown() == true then
- turtle.digDown()
- end
- if turtle.detect() then
- turtle.dig()
- end
- if checkWoodUp() == true then
- turtle.digUp()
- end
- end
- function checkJungleBranch()
- --SIDE1__BLOCK1
- if checkWood() == true then
- turtle.dig()
- tf()
- jc()
- tu()
- cutBranch1()
- td()
- else
- tf()
- tr()
- end----------------------------------------------
- if checkWoodUp() == true then
- tl()
- for i = 1, 2 do
- turtle.digUp()
- tu()
- end
- cutBranch1()
- td()
- td()
- end
- if checkWoodDown() == true then
- tl()
- cutBranch1()
- end
- --BLOCK2
- if checkWood() == true then
- turtle.dig()
- tu()
- tl()
- cutBranch1()
- td()
- else
- tf()
- end
- if checkWoodUp() == true then
- tl()
- for i = 1, 2 do
- turtle.digUp()
- tu()
- end
- cutBranch1()
- td()
- td()
- end
- if checkWoodDown() == true then
- tl()
- cutBranch1()
- end
- --CORNER
- if checkWood() == true then
- dc()
- tf()
- jc()
- tu()
- cutBranchC()
- td()
- else
- tf()
- tr()
- end
- --SIDE 2
- --check branch up3
- --check branch down3
- --check branch forward1
- tf()
- --check branch up1
- --check branch down1
- --check branch forward2
- tf()
- --check branch up2
- --chech branch down2
- --check branch forward3
- tf()
- tr()
- --SIDE 3
- --check branch up3
- --check branch down3
- --check branch forward1
- tf()
- --check branch up1
- --check branch down1
- --check branch forward2
- tf()
- --check branch up2
- --chech branch down2
- --check branch forward3
- tf()
- tr()
- --SIDE 4
- --check branch up3
- --check branch down3
- --check branch forward1
- tf()
- --check branch up1
- --check branch down1
- --check branch forward2
- tf()
- --check branch up2
- --chech branch down2
- --check branch forward3
- tr()
- tf()
- tl()
- for i = 1, 3 do
- td()
- height = height - 1
- end
- end
- function jungleTree()
- local success, data = turtle.inspectUp()
- if data.metadata == 3 and data.name == "minecraft:log" then
- print("wood detected up")
- turtle.digUp()
- turtle.up()
- height = height + 1
- top = top + 1
- print("Height ", height)
- if turtle.detect() then
- print("Wood detected")
- repeat
- turtle.dig()
- turtle.digUp()
- tu()
- height = height + 1
- top = top + 1
- print("Height ", height)
- until
- checkWoodUp() == false
- turtle.dig()
- tf()
- tr()
- turtle.dig()
- tf()
- tr()
- turtle.dig()
- for i = 1, height do
- turtle.digDown()
- td()
- height = height - 1
- turtle.dig()
- end
- if top>=25 and top<=50 then
- for i = 1, top - 1 do
- tu()
- hieght = height + 1
- end
- for i = 1, 5 do
- checkJungleBranch()
- height = height - 3
- end
- elseif top>=15 and top<=24 then
- for i = 1, top - 1 do
- tu()
- height = height + 1
- end
- for i = 1, 3 do
- checkJungleBranch()
- print("Height ", height)
- end
- elseif top>=8 and top<=14 then
- for i = 1, top - 1 do
- tu()
- height = height + 1
- end
- tf()
- for i = 1, 2 do
- checkJungleBranch()
- end
- end
- for i = 1, height do
- turtle.dig()
- turtle.digDown()
- td()
- end
- turtle.dig()
- tr()
- tf()
- tr()
- end
- end
- end
- function oak()
- local success, data = turtle.inspectUp()
- if data.metadata == 0 and data.name == "minecraft:log" then
- print("Oak Found")
- if checkWoodUp() == true then
- repeat
- turtle.digUp()
- print("Cutting Oak")
- tu()
- height = height + 1
- until checkWoodUp() == false
- end
- if height >5 then
- td()
- td()
- height = height - 2
- for i = 1, 2 do
- dc()
- tf()
- dc()
- tr()
- end
- for i= 1, 2 do
- dc()
- tf()
- dc()
- tf()
- dc()
- tr()
- end
- for i = 1, 2 do
- for i = 1, 3 do
- dc()
- tf()
- end
- tr()
- end
- for i = 1, 2 do
- for i = 1, 4 do
- dc()
- tf()
- end
- tr()
- end
- for i = 1, 2 do
- for i = 1, 5 do
- dc()
- tf()
- end
- tr()
- end
- for i = 1, 3 do
- for i = 1, 6 do
- dc()
- tf()
- end
- tr()
- end
- for i = 1, 2 do
- for i = 1, 3 do
- tf()
- end
- tr()
- end
- tr()
- end
- end
- end
- --Tree cutting function--
- function cut()
- height = 0
- oak()
- jungleTree()
- if checkWoodUp() == true then
- repeat
- turtle.digUp()
- print("Cutting Regular Tree")
- tu()
- height = height + 1
- until not turtle.detectUp()
- for i = 1, height do
- td()
- end
- end
- end
- --Move function--
- function move()
- repeat
- turtle.down()
- until
- turtle.detectDown()
- if checkIgnoreDown() == false then
- repeat
- turtle.digDown()
- td()
- until
- checkIgnoreDown() == true
- end
- if checkIgnore() == true then
- repeat
- tu()
- until
- checkIgnore() == false
- end
- turtle.dig()
- tf()
- cut()
- end
- -- Next row functions--
- function nextRowLeft()
- tl()
- move()
- tl()
- end
- function nextRowRight()
- tr()
- move()
- tr()
- end
- -----MAIN-----
- print("Input Length")
- givenLength = read()
- print("Input Width")
- givenWidth = read()
- for i = 1, givenWidth do
- for i = 1, givenLength do
- move()
- end
- if direction == 1 then
- nextRowLeft()
- direction = 2
- else
- nextRowRight()
- direction = 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement