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

[lua] tree felling program

Started by VVaojne, 31 December 2012 - 04:55 AM
VVaojne #1
Posted 31 December 2012 - 05:55 AM
I've created a code to plant saplings, bone meal and chop it down. But at the moment all it does is chop the first block and go straight to the end code, which is to turn around.
I'm sure its a simple mistake but i have no idea :/


print ("Bonemeal in 1")
print ("Saplings in 2 ")
print (" How Many Times? ")
-- Variables --
local treeheight = 0
local amount = read()
-- Functions --
local function turnaround()
  for q = 1, 2 do
	turtle.turnLeft()
  end
  turtle.forward()
  for e = 1, 2 do
	turtle.turnLeft()
  end
end
local function plant()
  turtle.select(1)
  turtle.place()
  turtle.select(2)
  turtle.place()
end
local function timber()
  while turtle.detectUp() do
	turtle.digUp()
	turtle.up()
	treeheight = treeheight + 1
  end
end  
-- Main Code --
for i = 1, amount do
  plant()
  sleep(1)
  turtle.dig()
  turtle.forward()
  timber()
  for w = 1, treeheight do
	turtle.down()
  end
  turnaround()
end
Tsa6 #2
Posted 31 December 2012 - 06:25 AM
Does it have fuel?
VVaojne #3
Posted 31 December 2012 - 08:22 AM
Does it have fuel?

…no it did not. i refueled it through the lua then it cut down the tree, but started making a staircase.. guess i got something else wrong