Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local xcord=
- local ycord=
- local zcord=
- local function checkFuel()
- if turtle.getFuelLevel() < 100 then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- function locate()
- g = vector.new(gps.locate(5))
- turtle.digUp()
- turtle.up()
- turtle.dig()
- turtle.forward()
- g2 = vector.new(gps.locate(5))
- turtle.back()
- turtle.down()
- if g.x == g2.x then
- if g.y > g2.y then
- turtle.turnLeft()
- turtle.turnLeft()
- else
- end
- else
- if g.x > g2.x then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- end
- function calc()
- xmove = xcord - g.x
- if xmove < 0 then xmove=xmove*(-1) end
- ymove = ycord - g.y
- if ymove < 0 then ymove=ymove*(-1) end
- zmove = zcord - g.z
- if zmove < 0 then zmove=zmove*(-1) end
- end
- function digForward()
- turtle.dig()
- turtle.forward()
- checkFuel()
- end
- function move()
- if xcord ~= g.x then
- if xcord < g.x then
- turtle.turnRight()
- for i=1,xmove do
- digForward()
- end
- turtle.turnLeft()
- else
- turtle.turnLeft()
- for i=1,xmove do
- digForward()
- end
- turtle.turnRight()
- end
- end
- if ycord ~= g.y then
- if ycord > g.y then
- for i=1,ymove do
- digForward()
- end
- else
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,ymove do
- digForward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- if zcord ~= g.z then
- if zcord < g.z then
- for i=1,zmove do
- checkFuel()
- turtle.digDown()
- turtle.down()
- end
- else
- for i=1,zmove do
- checkFuel()
- turtle.digUp()
- turtle.up()
- end
- end
- end
- end
- local function startup()
- print("coal in slot 1")
- print("saplings in slot 2")
- print()
- print("starting in 5")
- sleep(5)
- end
- local function column()
- local height = 0
- while turtle.digUp() do
- turtle.dig()
- checkFuel()
- turtle.up()
- height = height + 1
- end
- turtle.dig()
- checkFuel()
- return height
- end
- local function columnDown(height)
- for i=1,height do
- checkFuel()
- turtle.dig()
- turtle.digDown()
- turtle.down()
- end
- turtle.dig()
- end
- local function digmove()
- checkFuel()
- turtle.dig()
- turtle.forward()
- end
- local function fell()
- digmove()
- local height = column()
- turtle.turnRight()
- digmove()
- turtle.turnLeft()
- columnDown(height)
- end
- local function fellcrash()
- digmove()
- local height = column()
- turtle.turnLeft()
- digmove()
- turtle.turnRight()
- columnDown(height)
- end
- local function replant()
- turtle.select(2)
- turtle.place()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.place()
- turtle.turnRight()
- turtle.place()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- for slot=3,9 do
- turtle.select(slot)
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.select(2)
- turtle.place()
- while turtle.compare()==true do
- sleep(30)
- turtle.select(2)
- end
- end
- function needCoal()
- return turtle.getItemCount(1) < 10
- end
- function needSap()
- return turtle.getItemCount(2) < 10
- end
- function getSap()
- turtle.select(2)
- turtle.suckDown()
- turtle.select(3)
- turtle.dropDown()
- while turtle.getItemCount(2) < 60 do
- turtle.suckDown()
- turtle.select(3)
- turtle.dropDown()
- turtle.select(2)
- end
- end
- function getCoal()
- turtle.select(1)
- turtle.turnLeft()
- turtle.suck()
- turtle.select(3)
- turtle.drop()
- while turtle.getItemCount(1) < 60 do
- turtle.suck()
- turtle.select(3)
- turtle.drop()
- turtle.select(1)
- end
- turtle.turnRight()
- end
- startup()
- locate()
- calc()
- move()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- fellcrash()
- turtle.back()
- while true do
- if needSap() then
- getSap()
- end
- if needCoal() then
- getCoal()
- end
- fell()
- replant()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement