Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local t = 4
- local h = 0
- local s = 16
- local tArgs = {...}
- if #tArgs < 1 then
- print("Usage: trees <area>")
- return
- end
- --[[function home()
- rednet.open("right")
- loc = {gps.locate(3,false)}
- if loc[1],loc[2],loc[3] ~= -466, 63, 2298 then
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- tempLoc = {gps.locate(3,false)}
- turtle.back()
- if loc[1] - tempLoc[1] == 1 then
- dir = 2
- elseif
- loc[1] - tempLoc[1] == -1 then
- dir = 0
- turtle.turnLeft()
- turtle.turnLeft()
- elseif
- loc[3] - tempLoc[3] == 1 then
- dir = 3
- turtle.turnLeft()
- elseif
- loc[3] - tempLoc[3] == -1 then
- dir = 1
- turtle.turnRight()
- end
- travel = {loc[1] - -466, loc[2] - 63, loc[3] - 2298}
- if travel[1] > 0 then
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1,travel[1] do
- if turtle.detect()then
- turtle.dig()
- end
- turtle.forward()
- end
- elseif travel[1] < 0 then
- for i = travel[1],0 do
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- end
- end
- if travel[3] < 0 then
- end
- ]]--
- function usage()
- print("Place saplings into slot 2, and a single piece of wood that corresponds to the type of sapling you are using into slot 1")
- end
- function check()
- if turtle.getItemCount(1) == 0 or turtle.getItemCount(2) == 0 then
- print(usage())
- exit()
- end
- end
- function failsafe()
- turtle.select(2)
- if turtle.compare() == false then
- turtle.select(1)
- if turtle.compare() == false then
- print("Lost. Quitting for safety")
- end
- exit()
- end
- end
- function fwd()
- if turtle.detect() then
- turtle.dig()
- end
- turtle.attack()
- turtle.forward()
- end
- function cut()
- turtle.select(1)
- if turtle.compare() then
- turtle.dig()
- turtle.forward()
- while turtle.compareUp() do
- turtle.digUp()
- turtle.up()
- h = h + 1
- end
- for i = 1,h do
- turtle.down()
- end
- turtle.back()
- end
- turtle.select(2)
- turtle.place()
- end
- function move()
- turtle.turnRight()
- for i = 1,2 do
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- end
- turtle.turnLeft()
- end
- function line()
- for i = 1,tArgs[1]-1 do
- cut()
- move()
- end
- cut()
- end
- function switchLine()
- turtle.turnLeft()
- for i = 1,(tArgs[1]*2-1) do
- turtle.forward()
- end
- turtle.turnLeft()
- for i = 1,2 do
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- end
- turtle.turnLeft()
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- turtle.turnLeft()
- end
- function deposit()
- local tWood = turtle.getItemCount(1)
- local tSaplings = turtle.getItemCount(2)
- turtle.turnLeft()
- for i = 1,tArgs[1]*2-1 do
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- end
- turtle.turnRight()
- for i = 1,tArgs[1]*2-2 do
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.select(2)
- turtle.suck()
- turtle.drop(1)
- turtle.select(1)
- turtle.drop(tWood - 1)
- for i = 3,16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- if turtle.detect() then
- turtle.dig()
- end
- turtle.forward()
- end
- turtle.turnLeft()
- end
- local s = 10
- while true do
- check()
- for i = 1,tArgs[1]-1 do
- line()
- switchLine()
- end
- line()
- deposit()
- failsafe()
- s = 10
- for i = 1,10 do
- term.clear()
- term.setCursorPos(1,1)
- print("Waiting "..s.." minutes for the trees to grow")
- s = 10 - i
- sleep(60)
- end
- end
Add Comment
Please, Sign In to add comment