This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Marv-inside's profile picture

Lumberjack

Started by Marv-inside, 27 February 2012 - 11:46 PM
Marv-inside #1
Posted 28 February 2012 - 12:46 AM
!!!IMPORTANT: this script is for Redpower2 and works only with Redpower2!!!
This is my second program in Lua.
To get it to work you have to build it like this:

Front of the Turtle: Bundled Cable
you can use a deployer (redpower2 Item) for bonemeal (use the white cable)
use the brown cable with a Redstone repeater (vannilia repeater) to detect if the Tree has grown
Optional: if you are on bukkit and you have Craftbook installed, then you can use the red cable to burn down Leaves!
pictures later…


term.clear()
term.setCursorPos(1,1)
while turtle.detect() do
print"Tree detected!"
print"Starting to cut..."
while turtle.detect() do --detect if a block is in front of the Turtle
  turtle.dig() --destroy block
  if turtle.detectUp() then -- detect if a block is over the turtle
   turtle.digUp() --destroy block
  end
  turtle.up() --move up
end
end
while not turtle.detect() and not turtle.detectDown() do
print"Tree cutted!"
while not turtle.detect() and not turtle.detectDown() do --if ther is no block above or before th turtle, the turtle will go down to the start
  turtle.down()
end
end
t1=0
while not turtle.detect() do --check if there is a block
--print("No Tree detected, starting to sleep for 3 Seconds.")
sleep(3)
if turtle.detectDown() == true then --check if there is an block below
  turtle.select(9) --place sapling
  print("Placing a new Sapling")
  turtle.place()
  sleep(1)
  print"Using Bonemeal..."
  rs.setBundledOutput("back",colors.white)
  sleep(1)
  rs.setBundledOutput("back",0)
end
while true do
term.clear()
term.setCursorPos(1,1)
  print("Waiting for Tree to grow...")
  while rs.getBundledInput("back", "Brown") == 4096 do
   print"Tree grown!"
   sleep(1)
   shell.run("lumberjack")
  end
   t1=1+t1
   t2=(60-t1)
   print(t2)
   term.setCursorPos(4,2)
   print("Seconds till FIRE!!!")
   sleep(1)
   if t1 == 60 then
    term.clear()
    term.setCursorPos(1,1)
    print"Burning tree Down!!!"
    rs.setBundledOutput("back",colors.red)
    sleep(15)
    rs.setBundledOutput("back",0)
    sleep(15)
    turtle.select(9) --place sapling
print""
    print("Placing Sapling")
    turtle.place()
    sleep(3)
print""
print"Using Bonemeal..."
    rs.setBundledOutput("back",colors.white)
    sleep(1)
    rs.setBundledOutput("back",0)
    t1 = 0
  end
--end
end
end
elminister #2
Posted 03 March 2012 - 03:47 AM
it would be nice to add a picture of the setup :unsure:/>/>