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

TreeChopper

Started by KillmebecauseCCissoawesome, 22 April 2013 - 08:19 AM
KillmebecauseCCissoawesome #1
Posted 22 April 2013 - 10:19 AM
hello guys. i know that there are a lot of these types of programs but I want to show you what i have made. i present to you, the Tree-chopper
Spoilerterm.clear()
term.setCursorPos(1,1)
print("TREE CHOPPER v 3.0")
print("-Made by KrafterKing")– (me)
turtle.refuel(5)
print("place me by a tree then press C to chop down tree")
local event, param1 = os.pullEvent ("char")
if param1 == "c" then do
turtle.detect()
turtle.dig()
turtle.forward()
while turtle.detectUp() do
turtle.digUp()
turtle.up()
end
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
end
print("hello, the job is done.")
print("do you want to craft into planks? press Y for yes or N for no")
local event, param2 = os.pullEvent ("char")
local event, param3 = os.pullEvent ("char")
if param2 == "y" then do
turtle.craft()
turtle.select(2)
turtle.transferTo(12,64)
end
else
if param3 == "n" then do
print("not crafting, you may take your wood now.")
end
end
end
end
now, it only chops down single trees but i will update it to make a building that will collect the saplings, and possibly replant them. i hope you liked it. :D/>
if you have any thing that might help, like codes that would make it easier to code this then feel free to say so in the comments. :D/>
PS: you will need a crafty turtle if you want to do the wood into planks.
PSS: here is the pastebin for it: http://pastebin.com/UMmdStDv
unobtanium #2
Posted 22 April 2013 - 10:34 AM
Hello there,

Some neat ideas you had there :D/>
But i think most stuff can be made a little bit more effective:

Spoiler

--REFUEL PART
turtle.select(1)
while turtle.getFuelLevel() < 400 do
turtle.refuel(1)
sleep(0.5)
end
--Then you can go and remove the ask for the user to start the program. If the turtle is ready it starts automatically. If not the user has to put fuel into slot 1
turtle.detect() -- Dont know what this is for because you dont dont check it with an if statement. Just remove it.
turtle.select(2) --Select slot 2 to let the turtle place blocks into this. You will need this if you want planks later.
turtle.dig()
turtle.forward()
while turtle.detectUp() do
turtle.digUp()
turtle.up()
end
--The turtle.down()s can be removed with this while-loop. It checks if a block is underneath it and if not it goes down a block
while not turtle.detectDown() do
turtle.down()
end
print("hello, the job is done.")
print("do you want to craft into planks? press Y for yes or N for no")
local event, param2 = os.pullEvent ("char")
local event, param3 = os.pullEvent ("char") --Why do you ask twice? Remove this one!
if param2 == "y" then do
turtle.craft()
turtle.select(2)
turtle.transferTo(12,64)
--There was end before which didnt matched there
elseif param2 == "n" then do -- Use elseif and param2 instead of param3
print("not crafting, you may take your wood now.")
end
I think some parts wont work either :/ Did you tested it before?


PS: Pastebin is liked a lot on this forum^^
PSS: Mention that you need a crafty turtle to do the wood-into-planks stuff.
KillmebecauseCCissoawesome #3
Posted 22 April 2013 - 11:15 AM
it will work. i tested it a thousand times when finally it work when i put the last end so yes it will work.
and also the while loop. i did that but i think you should do while not turtle.detectUp() would be another option instead of turtle.detectDown() anyway, thanks for the advice
unobtanium #4
Posted 22 April 2013 - 11:36 AM
But you want the turtle to go down, right? Then you have to check if there are blocks down below and not above :D/>
KillmebecauseCCissoawesome #5
Posted 22 April 2013 - 12:10 PM
i added the pastebin and i did the detect down thing
sasaa_86 #6
Posted 01 May 2013 - 07:25 AM
bit ineffective to go down…




turtle.dig()
turtle.refuel()
turtle.forward()
while turtle.digUp() do
  turtle.up()
  -- this will break if it can't dipUp (end of the tree)
end
while turtle.down() do
  -- this will break if it can't go down
end

very effective… I use it as a function…

plus you asking to press a key to make planks but the end user has to press y or n twice
you can use the same variable twice ;P

print("do you want to craft into planks?")
print("press Y for yes or N for no")
local event, awnser = os.pullEvent ("char")
if awnser == "y" or awnser == "Y" then do
turtle.craft()
turtle.select(2)
turtle.transferTo(12,64)
elseif awnser == "n" or awnser == "N" then do
print("not crafting, you may take your wood now.")
end

or just leave the no part out since it does nothing…

print("do you want to craft into planks?")
print("press Y for yes or N for no")
local event, awnser = os.pullEvent ("char")
if awnser == "y" or awnser == "Y" then do
turtle.craft()
turtle.select(2)
turtle.transferTo(12,64)
end


making it run on key press i nice tho…
keep it up :D/>
theoriginalbit #7
Posted 17 May 2013 - 04:35 AM
-snip-
Do not be impatient. we saw your post here… however as with this post you are not posting in the correct spot! I suggest you read the forum guidelines before making any more posts. Specifically the part that targets new users
For new members, please note that you must have three approved posts before being able to create a new topic. This is to prevent a recent flood of spam we have been getting. If you need a question answered, please post a response here.

So again questions about your programs, and getting help with your programs, goes here, do not hijack other peoples threads!

However in this case DO NOT post your question for a third time, I have requested that the posts you have made be moved to the correct section, just be patient and we will answer your question when it is in the correct section.
unzzenedy #8
Posted 17 May 2013 - 04:47 AM
Okay, sorry about that! Wount do that again.

Thx for answer