Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local treeSpace=3
- local rowNum=7
- local colNum=7
- local x = 0
- local y = 0
- local z = 0
- local facing = 1
- numLogs = 1
- numSaps = 63
- logSlot = 1
- sapSlot = 3
- fuelSlot = 2
- ---------------------------------------
- -- 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 --
- ---------------------------------------
- function home()
- -- Orient
- if facing == 1 then
- tl()
- elseif facing == 2 then
- tl()
- tl()
- elseif facing == 3 then
- tr()
- end
- -- Travel Home
- gf()
- x = x - 1
- tl()
- if z>0 then
- gd(z)
- z = 0
- end
- if y>0 then
- gf(y)
- y = 0
- end
- tr()
- if x>0 then
- gf(x)
- end
- end
- function refuel()
- if turtle.getFuelLevel()<80 then
- ss(fuelSlot)
- turtle.refuel(1)
- end
- end
- function chopTree()
- refuel()
- ss(logSlot)
- if turtle.compare() then
- df()
- numLogs = numLogs + 1
- gf()
- dd()
- numLogs = numLogs + 1
- ss(logSlot)
- while turtle.compareUp() do
- du()
- numLogs = numLogs + 1
- gu()
- z = z + 1
- end
- for i=1,z do
- gd()
- end
- z = 0
- ss(sapSlot)
- pd()
- numSap = numSaps - 1
- else
- gf()
- end
- end
- function btwTree()
- for j=1,3 do
- if turtle.detect() then
- df()
- end
- gf()
- --sd(5)
- end
- end
- function chopRow()
- for i=1,rowNum - 1 do
- btwTree()
- chopTree()
- end
- end
- function chopFarm()
- btwTree()
- chopTree()
- for i=1,colNum-1 do
- chopRow()
- if i%2 == 1 then
- tr()
- btwTree()
- chopTree()
- tr()
- else
- tl()
- btwTree()
- chopTree()
- tl()
- end
- end
- chopRow()
- x = 24
- y = 28
- home()
- end
- function dropOffFuel ()
- gf()
- gd()
- ss(fuelSlot)
- Dd()
- gu()
- gb()
- end
- function dropOffLoot ()
- tl()
- gf()
- gd()
- ss(logSlot)
- Dd(turtle.getItemCount(logSlot)-17)
- ss(sapSlot)
- Dd()
- for i = 4,16 do
- ss(i)
- Dd()
- end
- numLogs = 1
- ss(fuelSlot)
- turtle.craft(64)
- turtle.suckDown(63)
- numSaps = 63
- gu()
- gb()
- tl()
- tl()
- end
- ---------------------------------------
- --------- MAIN ---------
- ---------------------------------------
- refuel()
- chopFarm()
- dropOffFuel()
- dropOffLoot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement