Advertisement
Jkerr

Minecraft Turtle Program - 2x2 tree feller

Feb 21st, 2013
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. term.clear()
  2. print("Start facing a 2x2 tree, lower left block")
  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.     turtle.dig()
  27.     turtle.forward()
  28.     turtle.turnRight()
  29.     turtle.dig()
  30.     turtle.forward()
  31.     turtle.turnRight()
  32.     turtle.dig()
  33.     turtle.forward()
  34.     turtle.turnRight()
  35.     turtle.forward()
  36.     turtle.turnRight()
  37.     forward = 1
  38.   end
  39. end
  40.  
  41. function mineTree()
  42.   if (forward == 1) then
  43.      if turtle.detectUp() then
  44.        detect = true
  45.      else
  46.        detect = false
  47.      end
  48.      while detect do
  49.        if turtle.detectUp() then
  50.          turtle.digUp()
  51.          turtle.up()
  52.          turtle.dig()
  53.           turtle.forward()
  54.           turtle.turnRight()
  55.           turtle.dig()
  56.           turtle.forward()
  57.           turtle.turnRight()
  58.           turtle.dig()
  59.           turtle.forward()
  60.           turtle.turnRight()
  61.           turtle.forward()
  62.           turtle.turnRight()
  63.          height=height+1
  64.        else
  65.          detect = false
  66.        end
  67.      end
  68.   end
  69. end
  70.  
  71. function reset()
  72.   if(forward == 1) then
  73.      if height>0 then
  74.          for i=0,height,1 do
  75.           turtle.down()
  76.           height=height-1
  77.          end
  78.      end
  79.   end
  80.   forward = 0
  81.   turtle.select(1)
  82. end
  83.  
  84. iniMove()
  85. mineTree()
  86. reset()
  87.  
  88. print("---------------------")
  89. print("Ending turtle fuel:")
  90. print(turtle.getFuelLevel())
  91. print("Fuel used:")
  92. print(startingfuel-turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement