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

[err] Keep getting [string "quarry"]:12: '=' expected error

Started by splatt9990, 02 August 2012 - 02:59 AM
splatt9990 #1
Posted 02 August 2012 - 04:59 AM
I'm trying to write my first program. the idea behind the program is that it will (eventually) tell the mining turtle to quarry until it's full then offload its inventory into a chest and continue until it hits bedrock. Currently it only (should) tell the turtle to mine out a 10x10 block.

My code currently:
Spoiler
function digfloor()
	local i=0
	local j=1
	local forward=true
	while j>11 do
	  j=j+1
	   while i>10 do
		 i=i+1
		 turtle.forward()
		 turtle.dig()
	   end
	 If forward==true then
	   turtle.turnLeft()
	   turtle.dig()
	   turtle.forward()
	   turtle.turnLeft()
	   forward=false
	 else
	   turtle.turnRight()
	   turtle.dig()
	   turtle.forward()
	   turtle.turnRight()
	   forward= true
	 end
   end
end
local i=0
local y=rednet.receive() --gives the ability to start the process wirelessly
If y=="quarry" then
   while i<4 do
	i=i+1
	digfloor()
   end
end


It's probably just a syntax error but for the life of me I can't find it if it is.
Edit: I'm currently running on 1.3 (through the tekkit modpack)
P.S. yes I know excavate does something similar but it's more about learning the language than actual usefulness as code at this point.
ChiknNuggets #2
Posted 02 August 2012 - 05:32 AM
From What i can see you have used a capital 'I' on line 12 in the if statement, you have also done the same thing on line 29 so just change them both to lowercase and it should work fine
Lyqyd #3
Posted 02 August 2012 - 05:49 AM
You're setting j to 1 and then using a 'while j is greater than 11 do' loop, which will never execute. You're probably looking for j<11. The i loop has similar issues.
splatt9990 #4
Posted 02 August 2012 - 06:00 AM
[Resolved]
Turns out I shouldn't capitalize "If" statements…
I simplified the while statements with for statements since i want it to just dig a 10x10 hole
I actually retyped the code by hand the ">" symbols were errors in retyping if you were confused sorry