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

Need help with turtle program asap.

Started by arestan, 03 January 2015 - 06:00 PM
arestan #1
Posted 03 January 2015 - 07:00 PM
So i got into turtle programming a few days ago and i cant figure out what is wrong with my code.
I want the code to harvest and replant crops for me in a 12*7 area.
The error message i am geting is: Bios:338: [string "harvestL"]:2: '=' expected.
now i know when you get that error message you should look at that line and the line above more carefully and i did for 30 minutes and i am clueless to what is wrong with it so please help.
this is my code :

function = strip(length)
  for i=1, length, 1 do
  turtle.digDown()
  turtle.suckDown()
  turtle.placeDown()
  turtle.forward()
  end
end

function turnRight()
  turtle.turnRight()
  turtle.forward
  turtle.digDown()
  turtle.turnRight()
  turtle.placeDown()
end
function turnLeft()
  turtle.turnLeft()
  turtle.forward
  turtle.digDown()
  turtle.turnLeft()
  turtle.placeDown()
  end
function resPos(length)
  turtle.turnRight()
  for i=1, length, 1 do
   turtle.forward()
  end
  turtle.turnRight()
  turtle.dropUp()
end   strip(12)
  turnRight()
	strip(12)
   turnLeft()
	 strip(12)
	turnRight()
	  strip(12)
	 turnLeft()
	   strip(12)
	  turnRight()
		strip(12)
	   turnLeft()
	  strip(12)
	  resPos(12)
wieselkatze #2
Posted 03 January 2015 - 07:50 PM
That "=" in line 1 of your program is unnecessary - remove it. Other than that this code is fine.
It'd then look like this ( code is a bit neatened up ):

Spoiler

function strip(length)
  for i=1, length, 1 do
	turtle.digDown()
	turtle.suckDown()
	turtle.placeDown()
	turtle.forward()
  end
end

function turnRight()
  turtle.turnRight()
  turtle.forward()
  turtle.digDown()
  turtle.turnRight()
  turtle.placeDown()
end

function turnLeft()
  turtle.turnLeft()
  turtle.forward
  turtle.digDown()
  turtle.turnLeft()
  turtle.placeDown()
end

function resPos(length)
  turtle.turnRight()
  for i=1, length, 1 do
	turtle.forward()
  end
  turtle.turnRight()
  turtle.dropUp()
end

strip(12)
turnRight()
strip(12)
turnLeft()
strip(12)
turnRight()
strip(12)
turnLeft()
strip(12)
turnRight()
strip(12)
turnLeft()
strip(12)
resPos(12)

Also the brackets were missing in line 12.
Edited on 03 January 2015 - 06:55 PM
arestan #3
Posted 04 January 2015 - 10:13 AM
Thanks so much i got it working now :D/>