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

Mining Turtle Help

Started by mjhasdied1, 06 April 2014 - 11:55 PM
mjhasdied1 #1
Posted 07 April 2014 - 01:55 AM
Hello, im fairly new to lua, ive been trying to make a mining turtle program and every time i fix an error i just get a new one, but this one i just cant find where the error is coming from… ive looked through my code for about 30 min now and i just cant find where its wrong… i am getting the error "[string "tunnel"]:25: unexpected symbol" but i cant find any odd symbols in my code… plz help!

http://pastebin.com/bc52njab
CometWolf #2
Posted 07 April 2014 - 07:26 PM
idk man, this whole statement seems pretty odd

    if distance == 8 or
	    if distance == 16 or
	    if distance == 24 or
	    if distance == 32 or
	    if distance == 39
correct syntax is

if condition or otherCondition then
blipman17 #3
Posted 07 April 2014 - 08:04 PM
idk man, this whole statement seems pretty odd

	if distance == 8 or
		if distance == 16 or
		if distance == 24 or
		if distance == 32 or
		if distance == 39
correct syntax is

if condition or otherCondition then

no the

if "your statement" or
if  "another statement" then
"do stuff"
end
part is totaly valid in lua, you can almost have everywhere enters and space between stuff in lua. In other languages it is not valid, but the runtime environment handles them as non existing.

the part that is wrong though, is that he has one "end" to much as far as I see. But that is not his error.

you've got a lot of () not properly statet at line 30 and ongoing.
Edited on 07 April 2014 - 06:02 PM
CometWolf #4
Posted 07 April 2014 - 08:10 PM
Yeah… No. The problem isn't newlines or spaces, it's the additonal ifs.
blipman17 #5
Posted 07 April 2014 - 08:15 PM
would it be "elseif" then?
CometWolf #6
Posted 07 April 2014 - 08:20 PM
elseif is used when you wish to execute another piece of code instead, if the first codition failed. I can only assume he wants to execute the same piece of code if any of the conditions are true, meaning his usage of or is correct. However there should not be any if between a condition, the or statement following it, or the condition after the or statement. Assuming that last statement should be 40 and not 39, he could also drop the or thing entirely by using the modulo operator, since it would then check wether it's divisable by 8.

		if distance%8 == 0 then
Edited on 07 April 2014 - 06:22 PM
chardo440 #7
Posted 07 April 2014 - 09:08 PM
I see a lot of your turtle.place and the turtle.turnRight don't close themselves. I'm sure you know but turtle.place() and turtle.turnRight()

I'll play around with it when I get home to better help.
Edited on 07 April 2014 - 07:08 PM
LoneRangerGuy #8
Posted 07 April 2014 - 11:27 PM
I'm not a lua expert, but isn't the problem the extra ifs after the first one? Shouldn't it be:
if distance == 8 or
distance == 16 or
distance == 24 or
distance == 32 or
distance == 39
instead?