Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local gps = {0, 0}--Y axis and rotation for turtle
- --Goes back and forth between two blocks. detects when it hits end and goes back other way. Maybe waits a bit before restarting
- --Checks to see if a tree has grown. If it has then cut it down and replant, then continue.
- --when it resets it dumps its inventory other than fuel and 1 stack of saplings.
- local function chop() --Cuts down tree and resets position
- while turtle.detect() do
- turtle.dig()
- while not turtle.up() do
- turtle.digUp()
- end
- gps[1] = gps[1] + 1
- end
- for i = 1, gps[1] do
- turtle.down()
- end
- gps[1] = 0
- end
- local function replant() --replants tree
- turtle.select(2)
- turtle.place()
- turtle.select(1)
- end
- local function check() --turns, checks for a tree. If ok then chops and replants. then turns back
- if gps[2] == 0 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- local ok, data = turtle.inspect()
- if ok and data.name == "rustic:log" then
- chop()
- replant()
- end
- if gps[2] == 0 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- --crate is (17 x 9) 117 slots large
- local function dump() --dumps inventory except for fuel and 1 stack of saplings
- local ok, data = turtle.getItemDetail()
- if data and data.name == "actuallyadditions:block_giant_chest" then
- for i = 3, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- end
- turtle.select(1)
- end
- local function patrol() --goes forward until it hits a block, then turns around and does it again.
- check()
- while not turtle.forward() do
- if turtle.detect() then
- turtle.turnRight()
- turtle.turnRight()
- gps[2] = gps[2] + 180
- if gps[2] >= 360 then
- gps[2] = 0
- end
- else
- turtle.attack()
- end
- dump()
- check()
- end
- end
- local function refuel() -- checks if fuel is below 5000. True = goes to slot 1 and refuels. If no fuel, spits out an error and goes to get more
- if turtle.getFuelLevel() < 5000 then
- turtle.select(1)
- turtle.refuel(10)
- end
- end
- --Main code
- for t = 1, tArgs[1] * 5 do
- refuel()
- patrol()
- end
Add Comment
Please, Sign In to add comment