Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- print("Start facing a 2x2 tree, lower left block")
- startingfuel = turtle.getFuelLevel()
- print("-----------")
- print("Turtle fuel:")
- print(startingfuel)
- if (startingfuel<300) then
- print("--------------------------------------")
- print("Low on fuel! (should have at least 300)")
- return
- end
- height = 0
- trees = 0
- forward = 0
- detect = false
- turtle.select(1)
- function iniMove()
- if turtle.detect() then
- turtle.dig()
- turtle.forward()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- forward = 1
- end
- end
- function mineTree()
- if (forward == 1) then
- if turtle.detectUp() then
- detect = true
- else
- detect = false
- end
- while detect do
- if turtle.detectUp() then
- turtle.digUp()
- turtle.up()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- height=height+1
- else
- detect = false
- end
- end
- end
- end
- function reset()
- if(forward == 1) then
- if height>0 then
- for i=0,height,1 do
- turtle.down()
- height=height-1
- end
- end
- end
- forward = 0
- turtle.select(1)
- end
- iniMove()
- mineTree()
- reset()
- print("---------------------")
- print("Ending turtle fuel:")
- print(turtle.getFuelLevel())
- print("Fuel used:")
- print(startingfuel-turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement