Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local success = false
- local data = nil
- local facing = 1;
- local height = 0;
- ---------------------------------------
- -- BASIC FUNCTIONS FOR TURTLE CONTROL -
- ---------------------------------------
- local function gf(n)
- if n==nil then
- n=1
- end
- for i=1,n,1 do
- turtle.forward()
- end
- end
- local function gb(n)
- if n==nil then
- n=1
- end
- for i=1,n,1 do
- turtle.back()
- end
- end
- local function gu(n)
- if n==nil then
- n=1
- end
- for i=1,n,1 do
- turtle.up()
- end
- end
- local function gd(n)
- if n==nil then
- n=1
- end
- for i=1,n,1 do
- turtle.down()
- end
- end
- local function tl()
- turtle.turnLeft()
- if facing == 1 then
- facing = 4
- else
- facing = facing - 1
- end
- end
- local function tr()
- turtle.turnRight()
- if facing == 4 then
- facing = 1
- else
- facing = facing + 1
- end
- end
- local function pf() turtle.place() end
- local function pu() turtle.placeUp() end
- local function pd() turtle.placeDown() end
- local function df() return turtle.dig() end
- local function du() turtle.digUp() end
- local function dd() turtle.digDown() end
- local function sf() turtle.suck() end
- local function su(n)
- if n==nil then
- while turtle.suckUp() do end
- else
- for i=1,n do
- turtle.suckUp()
- end
- end
- end
- local function sd(n)
- if n==nil then
- while turtle.suckDown() do end
- else
- for i=1,n do
- turtle.suckDown()
- end
- end
- end
- local function Df() turtle.drop() end
- local function Du() turtle.dropUp() end
- local function Dd(n)
- if n==nil then n=64 end
- turtle.dropDown(n)
- end
- local function ss(s) turtle.select(s) end
- local function cf() turtle.compare() end
- local function cu() turtle.compareUp() end
- ---------------------------------------
- -- Building Blocks --
- ---------------------------------------
- local function lightUp()
- redstone.setOutput("back", true)
- redstone.setOutput("right", true)
- redstone.setOutput("left", true)
- redstone.setOutput("top", true)
- redstone.setOutput("bottom", true)
- end
- local function findLog()
- repeat
- tl()
- success, data = turtle.inspect()
- until data.name == "minecraft:log"
- end
- local function chop2x2()
- data = nil
- repeat
- height = height - 1
- dd()
- gd()
- findLog()
- df()
- findLog()
- df()
- until height == 0
- gu()
- end
- local function chopTree()
- success, data = turtle.inspect()
- if data.name == "minecraft:log" then
- df()
- gf()
- while success do
- success, data = turtle.inspectUp()
- if data.name == "minecraft:log" then
- du()
- gu()
- height = height + 1
- else
- break
- end
- end
- success, data = turtle.inspect()
- if data.name == "minecraft:log" then
- df()
- gf()
- du()
- findLog()
- df()
- gf()
- du()
- findLog()
- df()
- gf()
- du()
- gb()
- else
- gd()
- height = height - 1
- success, data = turtle.inspect()
- if data.name == "minecraft:log" then
- df()
- gf()
- findLog()
- df()
- gf()
- findLog()
- df()
- end
- end
- if data.name == "minecraft:log" then
- chop2x2()
- else
- repeat
- gd()
- height = height - 1
- until height == 0
- end
- else
- print("No tree found")
- end
- end
- ---------------------------------------
- --------- MAIN ---------
- ---------------------------------------
- chopTree()
- lightUp()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement