ArbitraryHubris

felling turtle 2x2 logging turtle

Jun 10th, 2013
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. -- Author: ArbitraryHubris
  2. -- place saplings in slot 1, bone meal in slot 2
  3.  
  4. unknown, saplings = 0, 1
  5.  
  6. local function plantSaplings()
  7.   -- clear and plant logs in 2x2 layout and return to starting position
  8.   print("Planting saplings")
  9.   turtle.select(1)
  10.   turtle.dig()
  11.   turtle.forward()
  12.   turtle.dig()
  13.   turtle.forward()
  14.   turtle.turnRight()
  15.   turtle.dig()
  16.   turtle.place()
  17.   turtle.turnLeft()
  18.   turtle.back()
  19.   turtle.place()
  20.   turtle.turnRight()
  21.   turtle.dig()
  22.   turtle.place()
  23.   turtle.turnLeft()
  24.   turtle.back()
  25.   turtle.place()
  26.   turtle.select(2)
  27.   turtle.place()
  28.   print("Saplings planted")
  29. end
  30.  
  31.  
  32. local function detectItem()
  33.   turtle.select(saplings)
  34.   if turtle.compare() then
  35.     -- print("Detected sapling")
  36.     return saplings
  37.   end
  38.   return unknown
  39. end
  40.  
  41.  
  42. local function fell()
  43.   height = 0
  44.   turtle.dig()
  45.   turtle.forward()
  46.   while turtle.detectUp() do
  47.     height = height + 1
  48.     turtle.digUp()
  49.     turtle.dig()
  50.     turtle.up()
  51.   end
  52.   turtle.turnRight()
  53.   turtle.dig()
  54.   turtle.forward()
  55.   turtle.turnLeft()
  56.   while height > 0 do
  57.     turtle.dig()
  58.     turtle.digDown()
  59.     turtle.down()
  60.     height = height - 1
  61.   end
  62.   turtle.down()
  63.   turtle.dig()
  64.   turtle.turnLeft()
  65.   turtle.forward()
  66.   turtle.turnLeft()
  67.   turtle.forward()
  68.   for i = 3,16 do
  69.     turtle.select(i)
  70.     turtle.drop()
  71.   end
  72.   turtle.turnLeft()
  73.   turtle.turnLeft()
  74. end
  75.  
  76.  
  77. local function waitForTree()
  78.   seconds = 0
  79.   while true do
  80.     print("Waiting for sapling to grow for " .. seconds .. " seconds")
  81.     os.sleep(10)
  82.     seconds = seconds + 10
  83.     if detectItem() ~= saplings then
  84.       return
  85.     end
  86.   end
  87. end
  88.  
  89.  
  90. while true do
  91.   plantSaplings()
  92.   waitForTree()
  93.   fell()
  94. end
Advertisement
Add Comment
Please, Sign In to add comment