Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local saplingSlot = 15
- local boneMealSlot = 16
- local bone, chop, empty, plant, wait, waitForKey, watch
- bone = function()
- turtle.select(saplingSlot)
- while turtle.getItemCount(boneMealSlot) > 1 and turtle.compare() do
- turtle.select(boneMealSlot)
- turtle.place()
- turtle.select(saplingSlot)
- end
- end
- chop = function()
- local height = 1
- local downSteps = 1
- turtle.select(1)
- turtle.dig()
- turtle.forward()
- while turtle.compareUp() do
- turtle.digUp()
- turtle.up()
- height = height + 1
- end
- for i = 1, height - 1 do
- turtle.down()
- end
- turtle.back()
- end
- empty = function()
- for slot = 1, 14 do
- if turtle.getItemCount(slot) > 0 then
- turtle.select(slot)
- turtle.dropUp()
- end
- end
- end
- plant = function()
- turtle.select(saplingSlot)
- while true do
- turtle.dropDown()
- turtle.suckDown()
- if turtle.getItemCount(saplingSlot) > 1 then
- break
- end
- wait(60)
- end
- if not turtle.place() then
- print 'Obstacle in front of Turtle or no ground to plant on'
- waitForKey(keys.enter)
- end
- end
- wait = function(seconds)
- seconds = seconds or 1
- local timerId = os.startTimer(seconds)
- local _, id
- repeat
- _, id = os.pullEvent 'timer'
- until id == timerId
- end
- waitForKey = function(key)
- local _, keyPressed
- repeat
- _, keyPressed = os.pullEvent 'key'
- until keyPressed == key
- end
- watch = function()
- turtle.select(saplingSlot)
- while turtle.compare() do
- wait(1)
- end
- end
- -- Main loop
- (function()
- print('Saplings in slot ', saplingSlot)
- print('Bone Meal in slot ', boneMealSlot)
- print 'Logs are output to top face'
- print 'Saplings are input from bottom face'
- print 'Press Enter when ready'
- waitForKey(keys.enter)
- while true do
- plant()
- bone()
- watch()
- chop()
- empty()
- end
- end)()
Advertisement
Add Comment
Please, Sign In to add comment