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

My very first program (a lumberjack)

Started by lahn, 12 October 2012 - 07:45 PM
lahn #1
Posted 12 October 2012 - 09:45 PM
So started with CC yesterday and have been following some tutorials.

but this time i made my own program from what i have learned. and i made a lumberjack.

there is maybe something that could have been made a bit better but i'am pretty happy about it.
but would love to get better anyone got some suggestions.


--defines how many tree to harvest
local times = 0
term.write("Number of trees to cut: ")
times = read()
for u = 1, times do
-- sets a vari for use when cutting the tree
local x = 0
--plants and bonemeals the tree
turtle.select(1)
turtle.place()
turtle.select(2)
turtle.place()
-- moves the turtle up
while turtle.detect() do
  turtle.digUp()
  turtle.up()
  x = x+1
end
--moves the turlte over the log
turtle.forward()
--cuts the tree and moves down depending on the vari x
for i = 1, x do
  turtle.digDown()
  turtle.down()
end
-- sets vari x to 0
x = 0
-- moves turtle over to chest and turns it around
turtle.back()
turtle.turnLeft()
turtle.turnLeft()
-- puts any tree and saplings into the chest
turtle.select(3)
turtle.drop()
turtle.select(4)
turtle.drop()
turtle.select(1)
-- turns the turtle around to the start position
turtle.turnLeft()
turtle.turnLeft()
end
jag #2
Posted 12 October 2012 - 10:41 PM
but would love to get better anyone got some suggestions.
Now, do you want the code better or do YOU want to get better?
1v2 #3
Posted 12 October 2012 - 10:57 PM
Definitely not bad for your first program. Keep on going.
ChunLing #4
Posted 12 October 2012 - 11:14 PM
You should add a turtle.compare() in there so that you know when the bonemeal has succeeded (it doesn't always with trees, particularly if you have leftover leaves/logs hanging in the air). You could also use a larger excavation pattern to clean up more logs/leaves, but if you're just using birch/spruce that's probably okay (though you might need an occasional suck patrol around the area, since those don't drop enough saplings with the pattern your using now).

A good start, and important given that trees are the most renewable and controllable source of fuel.
lahn #5
Posted 13 October 2012 - 04:55 PM
but would love to get better anyone got some suggestions.
Now, do you want the code better or do YOU want to get better?

i want both. i want to get better which will also make my code better :)/>/>

Definitely not bad for your first program. Keep on going.

thank you

You should add a turtle.compare() in there so that you know when the bonemeal has succeeded (it doesn't always with trees, particularly if you have leftover leaves/logs hanging in the air). You could also use a larger excavation pattern to clean up more logs/leaves, but if you're just using birch/spruce that's probably okay (though you might need an occasional suck patrol around the area, since those don't drop enough saplings with the pattern your using now).

A good start, and important given that trees are the most renewable and controllable source of fuel.

thanks for the sugestions will look into it.
adding turtle.compare() sounds like a good idea