Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tapTree()
- for i=1,4 do
- if ( i%2 == 1 ) then
- while ( turtle.detect() ) do
- turtle.dig()
- turtle.up()
- end
- else
- while ( not turtle.detectDown() ) do
- turtle.down()
- turtle.dig()
- end
- end
- if ( i ~= 4 ) then
- changeSides()
- end
- end
- end
- function changeSides()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- function changeTrees()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- function changeRows(rowNumber)
- turtle.turnRight()
- turtle.forward()
- if ( rowNumber % 2 == 0 ) then
- turtle.turnLeft()
- for i=1,3 do
- turtle.forward()
- end
- turtle.turnLeft()
- else
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- end
- function emptyInventory()
- for i = 1,16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- end
- function returnHome(treeCount, rowCount)
- if ( rowCount % 2 == 1 ) then
- turtle.turnLeft()
- for i=1,(treeCount*2) do
- turtle.forward()
- end
- turtle.turnRight()
- for i=1,(rowCount*2-1) do
- turtle.forward()
- end
- turtle.turnLeft()
- else
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- for i=1,((rowCount*2)-3) do
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.forward()
- end
- emptyInventory()
- turtle.turnRight()
- turtle.turnRight()
- end
- args={ ... }
- treeCount=tonumber(args[1])
- rowCount=tonumber(args[2])
- while true do
- print("Starting Resin Collection")
- print(string.format("There are %d Trees in %d Rows", treeCount, rowCount))
- turtle.forward()
- for i=1,rowCount do
- for j=1,treeCount do
- print(string.format("Starting Tree %d in Row %d", j, i))
- tapTree()
- if ( j ~= treeCount ) then
- changeTrees()
- end
- end
- print(string.format("Completed Row %d", i))
- if ( i ~= rowCount ) then
- changeRows(i)
- end
- end
- print("Completed Tree Tapping, Returning Home")
- returnHome(treeCount, rowCount)
- emptyInventory()
- print("Cycle Complete, sleeping for 5 minutes")
- sleep(300)
- end
Advertisement
Add Comment
Please, Sign In to add comment