Advertisement
Jkerr

Minecraft Turtle Program - 1x1 tree feller

Jul 3rd, 2013
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. term.clear()
  2. print("Start facing the bottom of a 1x1 tree")
  3.  
  4. startingfuel = turtle.getFuelLevel()
  5.  
  6. print("-----------")
  7. print("Turtle fuel:")
  8. print(startingfuel)
  9.  
  10. if (startingfuel<300) then
  11.    print("--------------------------------------")
  12.    print("Low on fuel! (should have at least 300)")
  13.    return
  14. end
  15.  
  16. height = 0
  17. trees = 0
  18. forward = 0
  19. detect = false
  20. turtle.select(1)
  21.  
  22. function iniMove()
  23.   if turtle.detect() then
  24.     turtle.dig()
  25.     turtle.forward()
  26.     forward = 1
  27.   end
  28. end
  29.  
  30. function mineTree()
  31.   if (forward == 1) then
  32.      if turtle.detectUp() then
  33.        detect = true
  34.      else
  35.        detect = false
  36.      end
  37.      while detect do
  38.        if turtle.detectUp() then
  39.          turtle.digUp()
  40.          turtle.up()
  41.          height=height+1
  42.        else
  43.          detect = false
  44.        end
  45.      end
  46.   end
  47. end
  48.  
  49. function reset()
  50.   if(forward == 1) then
  51.      if height>0 then
  52.          for i=0,height,1 do
  53.           turtle.down()
  54.           height=height-1
  55.          end
  56.      end
  57.   end
  58.   forward = 0
  59.   turtle.select(1)
  60. end
  61.  
  62. iniMove()
  63. mineTree()
  64. reset()
  65.  
  66. print("---------------------")
  67. print("Ending turtle fuel:")
  68. print(turtle.getFuelLevel())
  69. print("Fuel used:")
  70. print(startingfuel-turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement