Advertisement
kolyaventuri

TreeFell-Test

Jan 25th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. local function checkFuel()
  2.   if turtle.getFuelLevel() < 20 then
  3.     turtle.select(1)
  4.     turtle.refuel(1)
  5.   end
  6. end
  7.  
  8. local function column()
  9.   local height = 0
  10.   while turtle.digUp() do
  11.     turtle.dig()
  12.     checkFuel()
  13.     turtle.up()
  14.     height = height + 1
  15.   end
  16.   turtle.dig()
  17.   checkFuel()
  18.   return height
  19. end
  20.  
  21. local function columnDown(height)
  22.   for i=1,height do
  23.     checkFuel()
  24.     turtle.dig()
  25.     turtle.digDown()
  26.     turtle.down()
  27.   end
  28.   turtle.dig()
  29. end
  30.  
  31. local function digmove()
  32.   checkFuel()
  33.   turtle.dig()
  34.   turtle.forward()
  35. end
  36.  
  37. local function fell()
  38.   digmove()
  39.   local height = column()
  40.   turtle.turnRight()
  41.   digmove()
  42.   turtle.turnLeft()
  43.   columnDown(height)
  44. end
  45.  
  46. local function replant()
  47.   turtle.select(15)
  48.   turtle.suck()
  49.   turtle.place()
  50.   turtle.turnLeft()
  51.   turtle.suck()
  52.   turtle.forward()
  53.   turtle.suck()
  54.   turtle.turnRight()
  55.   turtle.suck()
  56.   turtle.place()
  57.   turtle.turnRight()
  58.   turtle.suck()
  59.   turtle.place()
  60.   turtle.turnRight()
  61.   turtle.suck()
  62.   turtle.forward()
  63.   turtle.suck()
  64.   for slot=3,7 do
  65.     turtle.select(slot)
  66.     turtle.drop()
  67.   end
  68.   turtle.turnLeft()
  69.   turtle.turnLeft()
  70.   turtle.select(15)
  71.   turtle.place()
  72.   turtle.select(2)
  73.   while not turtle.compare() do
  74.     turtle.select(16)
  75.     turtle.place()
  76.     turtle.select(2)
  77.   end
  78. end
  79.  
  80. function needCoal()
  81.   return turtle.getItemCount(1) < 10
  82. end
  83.  
  84. function needBonemeal()
  85.   return turtle.getItemCount(16) < 10
  86. end
  87.  
  88. while true do
  89.   fell()
  90.   replant()
  91.   if needCoal() then
  92.     print("Out of Coal")
  93.     break
  94.   end
  95.   if needBonemeal() then
  96.     print("Out of Bonemeal")
  97.     break
  98.    
  99.   end
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement