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

**HELP**

Started by sha263, 12 April 2013 - 09:00 PM
sha263 #1
Posted 12 April 2013 - 11:00 PM
i just wrote this script and it doesn't work. it should go forward 3 cut down a tree then go back to the start point and drop the wood. it doesn't work for me can someone tell me if i"m doing something wrong.

***PLZ HELP***

the code V

function reFuel()
if turtle.getFuelLevel() < 20 then
  for i=1,5
   turtle.refuel()
  end
end
end
function uTurn()
turtle.ternLeft()
turtle.turnLeft()
end
function toTree()
for i=1,3 do
  turtle.forward()
end
end
function cutTree()
turtle.dig()
turtle.forward()
while turtle.detectUp() do
  turtle.digUp()
  turtle.up()
end
while not turtle.detectDown() do
  turtle.down()
end
end
function toHome()
uTurn()
for i=1,3 do
  turtle.forward()
end
turtle.select(2)
turtle.drop()
turtle.select(3)
turtle.drop()
turtle.select(1)
end
function replantTree
turtle.select(1)
turtle.place()
end


--main script--
while true do
reFuel()
toTree()
cutTree()
replantTree()
toHome()
sleep (300)
end
Frederikam #2
Posted 12 April 2013 - 11:15 PM
Well…

Do you get an error or is the turtle just not doing what you want it to? If you get an error please post the error.
Senmori #3
Posted 12 April 2013 - 11:52 PM
Works fine for me once you fix the code. It's not the most efficient tree chopper ever made but it gets the job done.

http://pastebin.com/hqrPcBNP

Code:
Spoiler

function reFuel()
	if turtle.getFuelLevel() < 20 then
		 for i=1,5 do -- you were missing a 'do' here.
			  turtle.refuel()
		 end
	end
end

function uTurn()
	turtle.turnLeft() --  turtle.turnLeft() not ternLeft
	turtle.turnLeft()
end

function toTree()
	for i=1,3 do
	   turtle.forward()
	end
end

function cutTree()
	turtle.dig()
	turtle.forward()
	  while turtle.detectUp() do
		  turtle.digUp()
		  turtle.up()
	  end
	  while not turtle.detectDown() do
		  turtle.down()
	  end
end

function toHome()
	uTurn()
	  for i=1,3 do
		 turtle.forward()
	  end
	turtle.select(2)
	turtle.select(3)
	turtle.drop()
	turtle.select(1)
	end
  
function replantTree() -- you were missing the'()' here.
	turtle.select(1)
	turtle.place()
end


--main script--
while true do
reFuel()
toTree()
cutTree()
replantTree()
toHome()
sleep (300)
end
BlackMenthol #4
Posted 12 April 2013 - 11:53 PM
You forgot to put brackets in the replantTree function.


function replantTree
should be
function replantTree()

Hope it helps :P/>
If this isn't the problem, give us the error message :P/>
sha263 #5
Posted 13 April 2013 - 03:27 AM
thx for the help Clueless your code it fixed it :)/>
sha263 #6
Posted 13 April 2013 - 03:40 AM
clueless can u show me a more efficient tree logging script. plz :D/>
LBPHacker #7
Posted 13 April 2013 - 04:18 AM
clueless
Just to clarify :D/> His name is BlackMenthol, not clueless. The name can be found in

The blue field above the actual comment…

If you take a look at your comments, there's "clueless" above your avatar as well.
The more posts you have (you have 3 atm) the higher rank you have. Eg. I'm a "Coder" because I have more than 200 posts already.
Kingdaro #8
Posted 13 April 2013 - 04:30 AM
clueless can u show me a more efficient tree logging script. plz :D/>/>
There's a nice one on the wiki. You can edit it to suit your needs.

Just to clarify :D/>/> His name is BlackMenthol, not clueless. The name can be found in

The blue field above the actual comment…

If you take a look at your comments, there's "clueless" above your avatar as well.
The more posts you have (you have 3 atm) the higher rank you have. Eg. I'm a "Coder" because I have more than 200 posts already.
And I'm The Doctor, nice to meet you!
LBPHacker #9
Posted 13 April 2013 - 04:31 AM
-snip-
Wut? :D/>