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

Error with my first turtle program

Started by ColonySimulator, 08 November 2016 - 12:15 AM
ColonySimulator #1
Posted 08 November 2016 - 01:15 AM
Well I just made this basic code to chop stuff (wood , well it doesnt verifies , but I'm so noob at the moment). and I get this error

bios:14: [string "chopWood"]:12: '=' expected


SET_STEP = 5;
point = 1; -- position poiting to
stepDoneFW = 0; -- step done forward
stepDoneUP = 0; -- step done up
choppedNb = 0; -- number of stuff digged
chopped = false;

function chopTree()
	repeat
		turtle.up();
		turtle.dig();
		choppedNb++;
		stepDoneUP++;
	until !(turtle.detect())
	return stepDoneUP;
end

function move(step,direction)
	stepAccomplish = 0;
	for i=0;step do
		if direction == 'front' then
			if !(turtle.detect()) then
				stepAccomplish++;
				turtle.forward();
			else
				return stepAccomplish;
			end
		else
			turtle.back();
		end
	end
	return stepAccomplish + 1;
end

function Main()
	stepDoneFW = move(SET_STEP,'front');
	if (stepDone <= SET_STEP) then
		stepDoneUP = chopTree();
		for goDown = 0,stepDoneUP do
			turtle.down();
		end
	end
  
	move(stepDoneFW,'backward');
	turtle.turnRight();
end

while point != 1 do
		point++;
		if point > 4 then
			point = 1;
		end
		turtle.turnRight();
end
  
repeat
	Main();
until chopped

print("Buddy I found:" .. choppedNb .. " logs.There ya go chumps!");
Bomb Bloke #2
Posted 08 November 2016 - 02:13 AM
choppedNb++;

This is not valid Lua syntax.

Use:

choppedNb = choppedNb + 1;