Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local blockToMove = 99
- -- I've made refill a function so you could use it anywhere in the code. But for now
- -- this function will run at the start of each new loop to check if the turtle has
- -- enough items
- function refill()
- if turtle.getFuelLevel <= 50 then
- for i = 16,1,-1 do
- turtle.select(i)
- turtle.dropUp()
- end
- turtle.suckDown() --Code to pick up stacks of coal from chest
- turtle.refuel() --Code to refuel all
- turtle.turnRight()
- turtle.suck(1)
- turtle.turnRight()
- turtle.suck(2)
- turtle.turnLeft()
- turtle.turnLeft()
- print("Done Refueling")
- elseif turtle.getItemCount(1) == 0 then
- turtle.turnRight()
- turtle.suck(1)
- turtle.turnLeft()
- print("Refilled Saplings")
- elseif turtle.getItemCount(2) == 0 then
- turtle.turnRight()
- turtle.turnRight()
- turtle.suck(2)
- turtle.turnLeft()
- turtle.turnLeft()
- print("Refilled Bone Meal")
- end
- end
- -- Go home is now also a function, but this function should
- -- actually never be called since removeTree has a "homing" system
- function goHome()
- for attempt = 1, blocksToMove do
- local success, error = turtle.down()
- if not turtle.down() then
- turtle.back()
- print("Returned to Start")
- break
- end
- end
- end
- -- Remove tree is now also a function. It will
- function removeTree()
- local up = 1
- local tree = true
- -- While turtle.inspectUP is true and turtle.inspectup.name = a log, dig up
- while turtle.inspectUp() and turtle.inspectUp().name == "MineFactoryReloaded:rubberwood.log" do
- turtle.digUp()
- turtle.up()
- up = up + 1
- end
- -- Go down as many times as we went up
- for i = 1, up do
- turtle.down()
- end
- end
- -- Make this one big loop so it keeeeeps on going
- while true do
- -- First refill if needed
- refill()
- if turtle.detect() == false and turtle.detectUp() == false and turtle.detectDown() == false then
- -- This function should actually never run, since remove tree gets you home.
- -- Should go home
- goHome()
- else
- -- Check if there is anything in front of me
- local check, infront = turtle.inspect()
- if not check then
- -- No sapling and noving above me
- turtle.select(1)
- turtle.place()
- print("Placed Sapling")
- end
- -- Check if infront is a sapling. if so, place bonemeal. If it's a log, I should probably remove the tree
- if check and infront.name == "MineFactoryReloaded:rubberwood.sapling" then
- turtle.select(2)
- turtle.place()
- print("Used Bonemeal")
- elseif check and infront.name == "MineFactoryReloaded:rubberwood.log" then
- turtle.dig()
- turtle.forward()
- removeTree()
- turtle.back()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment