Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- temptree = 0 -- Pocet pokacenych stromu
- y = 1 -- pozice Y
- sfuel = 50 -- start fuel
- function unload() --unload
- for n = 3,16 do
- local nCount = turtle.getItemCount(n)
- if nCount > 0 then
- turtle.select(n)
- turtle.dropDown()
- end
- end
- turtle.select(1)
- end
- function compare() -- compare block / turn left
- turtle.select(1)
- while not turtle.compare() do
- turtle.turnLeft()
- sapling() -- check/place sapling
- os.sleep(5)
- end
- end
- function refueltest() -- check fuel in slot 1
- if turtle.getItemCount(1) == 0 then
- print("Get fuel to slot 1 and press enter")
- event, enter = os.pullEvent("key")
- return
- else
- refueling()
- end
- end
- function refueling() -- refueling to start fuel level
- while turtle.getFuelLevel() < sfuel do
- turtle.select(1)
- os.sleep(0.2)
- turtle.refuel(1)
- os.sleep(0.2)
- end
- end
- function moveup() -- move up
- while not turtle.up() do
- turtle.digUp()
- os.sleep(0.5)
- end
- end
- function compareup() -- compare/move up
- refueltest()
- turtle.select(1)
- while turtle.compareUp() do
- moveup()
- y = y + 1
- os.sleep(0.5)
- end
- end
- function movedown() -- move down
- while not turtle.down() do
- turtle.digDown()
- os.sleep(0.5)
- end
- end
- function moveback() -- move back
- while y > 1 do
- movedown()
- y = y - 1
- os.sleep(0.2)
- end
- end
- function sapling() -- place sapling
- turtle.select(16)
- if turtle.compare() == true then
- turtle.select(2)
- turtle.place()
- turtle.select(1)
- os.sleep(0.2)
- else
- turtle.select(1)
- os.sleep(0.2)
- end
- end
- function cutter() -- PROGRAM CORE
- if turtle.getItemCount(2) == 0 then -- check sapling slot before start
- print("Cutted trees: "..temptree)
- print("Get sapling to slot 2 and press key or press key to exit")
- print("or press key to exit")
- event, enter = os.pullEvent("key")
- if turtle.getItemCount(2) == 0 then
- os.reboot()
- else
- print("Continue cutting")
- end
- return
- end
- compare() -- Wait for tree
- if turtle.getFuelLevel() == 0 then
- refueltest()
- end
- while not turtle.forward() do -- Try forward
- turtle.dig()
- os.sleep(0.5)
- end
- compareup() -- cutting tree
- moveback() -- move down
- while not turtle.back() do -- move start position
- turtle.turnLeft()
- turtle.turnLeft()
- os.sleep(0.2)
- turtle.dig()
- turtle.turnLeft()
- turtle.turnLeft()
- os.sleep(0.2)
- end
- sapling() -- check/place sapling
- unload() -- unload
- temptree = temptree + 1 -- counting cutted tree
- end
- ---------------------------------------------------------------
- ---------------------------------------------------------------
- print("Place chest under turtle, get to slot 1 a few fuel & slot 2 a few sapling's")
- while true do
- cutter()
- end
- print("Pocet pokacenych stromu: "..temptree)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement