Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Updated to work with Minecraft 1.6.4
- -- Slot 1: Saplings
- -- Slot 2: Bonemeal
- -- Usage: treeFelling <trees> <chest side>
- -- "Trees" is how many saplings to grow and cut down. This is a numerical value.
- -- "Chest side" is the side a chest is to empty inventory into. "Back", "Left", "Right", and "Bottom" are supported
- -- If no arguments are given, one tree will be grown and cut-down with the inventory staying in the turtle.
- -- The second argument is optional, but if used the first is required.
- local trees = {...}
- local progEnd = 0
- function goUp()
- while turtle.up() == false do
- turtle.digUp()
- turtle.attackUp()
- end
- end
- function goDown()
- while turtle.down() == false do
- turtle.digDown()
- turtle.attackDown()
- end
- end
- function goForward()
- while turtle.forward() == false do
- turtle.dig()
- turtle.attack()
- end
- end
- function goBack()
- turtle.turnLeft()
- turtle.turnLeft()
- goForward()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function plant()
- turtle.select(1)
- if turtle.getItemCount(1) == 0 then
- print("Out of saplings, replace and press any key")
- print("Press 'Q' to quit")
- local event, param1 = os.pullEvent ("char")
- if param1 == "q" then
- progEnd = 1
- return
- end
- end
- turtle.place()
- turtle.select(2)
- if turtle.getItemCount(2) == 0 then
- print("Out of bonemeal, replace and press any key")
- print("Press 'Q' to quit")
- local event, param1 = os.pullEvent ("char")
- if param1 == "q" then
- progEnd = 1
- return
- end
- end
- while turtle.place() == true do
- end
- turtle.select(3)
- end
- function emptyInventory(dir)
- for i=3,16 do
- turtle.select(i)
- if turtle.compareTo(1) == true then
- turtle.transferTo(1)
- elseif turtle.compareTo(2) == true then
- turtle.transferTo(2)
- end
- end
- if string.lower(dir) == "back" then
- turtle.turnLeft()
- turtle.turnLeft()
- for i=3,16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- elseif string.lower(dir) == "bottom" then
- for i=3,16 do
- turtle.select(i)
- turtle.dropDown()
- end
- elseif string.lower(dir) == "left" then
- turtle.left()
- for i=3,16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.right()
- elseif string.lower(dir) == "right" then
- turtle.right()
- for i=3,16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.left()
- end
- end
- if #trees < 1 then
- trees[1] = 1
- elseif #trees >= 1 then
- if not tonumber(trees[1]) then
- local file = shell.getRunningProgram()
- if string.find(file, "/") ~= null then
- file = string.reverse(file)
- file = string.reverse(string.sub(file, 1, string.find(file, "/") - 1))
- end
- print("Usage: " .. file .. " <number> <side>")
- print("Number: amount of trees to be chopped")
- print("Side: Side output chest is on (optional)")
- return
- end
- end
- for i=1,trees[1] do
- local dist = 0
- plant()
- if progEnd == 1 then
- print("User exit")
- return
- end
- goForward()
- while turtle.detectUp() == true do
- goUp()
- dist = dist + 1
- end
- for o=1,dist do
- goDown()
- end
- goBack()
- if not trees[2] then
- trees[2] = "none"
- end
- emptyInventory(trees[2])
- end
- print("Program Complete")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement