Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gps = require("turtle_gps")
- Drop_in_world = false
- function check_inventory()
- -- check logs slot
- current_slot = 1
- over = turtle.getItemCount(current_slot)
- if over > 1 then
- turtle.select(current_slot)
- -- refuel
- while turtle.getFuelLevel() < 200 and over > 1 do
- turtle.refuel(1)
- over = over - 1
- end
- if over > 1 then
- if Drop_in_world then
- -- keeps 1 log to compare
- turtle.drop(over - 1)
- else
- while turtle.dropDown(over - 1) == false do
- print("Inventory full. Press ENTER to continue")
- read()
- end
- end
- end
- end
- -- check saplings slot
- current_slot = 2
- over = turtle.getItemCount(current_slot)
- if over < 5 then
- turtle.select(current_slot)
- turtle.suckDown(5 - over)
- end
- -- drop other slots' content
- for current_slot = 3, 16, 1 do
- over = turtle.getItemCount(current_slot)
- if over > 0 then
- turtle.select(current_slot)
- -- refuel
- while turtle.getFuelLevel() < 200 and over > 0 do
- turtle.refuel(1)
- over = over - 1
- end
- if Drop_in_world then
- turtle.drop()
- else
- while turtle.dropDown() == false do
- print("Inventory full. Press ENTER to continue")
- read()
- end
- end
- end
- end
- end
- function check_layer()
- did_cut = false
- turtle.select(1)
- turnToDirection(Directions.Forward)
- if turtle.compare() then
- turtle.dig()
- did_cut = true
- end
- turnToDirection(Directions.Right)
- if turtle.compare() then
- turtle.dig()
- did_cut = true
- end
- turnToDirection(Directions.Backwards)
- if turtle.compare() then
- turtle.dig()
- did_cut = true
- end
- turnToDirection(Directions.Left)
- if turtle.compare() then
- turtle.dig()
- did_cut = true
- end
- turnToDirection(Directions.Forward)
- return did_cut
- end
- function plant()
- -- select the sapling slot
- turtle.select(2)
- planted = 0
- if turtle.getItemCount(2) >= 5 then
- turnToDirection(Directions.Forward)
- if turtle.detect() == false then
- turtle.place()
- planted = planted + 1
- end
- turnToDirection(Directions.Right)
- if turtle.detect() == false then
- turtle.place()
- planted = planted + 1
- end
- turnToDirection(Directions.Backwards)
- if turtle.detect() == false then
- turtle.place()
- planted = planted + 1
- end
- turnToDirection(Directions.Left)
- if turtle.detect() == false then
- turtle.place()
- planted = planted + 1
- end
- else
- print("Out of saplings")
- end
- return planted
- end
- -------------------------------
- function main()
- Auto_refuel = false
- print("Please place 1 log in slot 1 and 5 saplings in slot 2 (less saplings can work)")
- print("_________________________________")
- print("Place a chest underneath the turtle to replenish saplings")
- print("_________________________________")
- print("Drop items in world [Y/n]? (when using [vacuum] hoppers)")
- if string.lower(read()) == 'y' then
- Drop_in_world = true
- term.clear()
- term.setCursorPos(1, 1)
- print("Turtle will drop items infront of it")
- else
- term.clear()
- term.setCursorPos(1, 1)
- print("Turtle will drop items in the inventory below it")
- end
- -- refuel
- turtle.select(16)
- while turtle.getFuelLevel() < 200 do
- print("Not enough fuel: "..turtle.getFuelLevel().." / 200")
- print("place fuel in slot 16 and Press ENTER to continue...")
- read()
- turtle.refuel()
- end
- print("_________________________________")
- print("The turtle will use logs to refuel during operation")
- print("Press ENTER to start logging")
- read()
- term.clear()
- term.setCursorPos(1, 1)
- read_position()
- print("Turtle is now logging trees...")
- if plant() > 0 then
- sleep(10)
- end
- while true do
- if check_layer() then
- if turtle.detectUp() then
- turtle.digUp()
- end
- moveTo(0,0,Local_z + 1, 'xyz')
- else
- if Local_z > 0 then
- moveTo(0,0,0, 'xyz')
- check_inventory()
- if plant() > 0 then
- sleep(10)
- end
- else
- sleep(10)
- end
- end
- end
- end
- main()
Add Comment
Please, Sign In to add comment