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

Mining program not working: bios:337: [string "Mine"]:45:'=' expected

Started by wrkaqarg1, 16 September 2013 - 12:46 AM
wrkaqarg1 #1
Posted 16 September 2013 - 02:46 AM
Title: Mining program not working… need help I'm pretty new to computer craft and I'm also quite new to coding, but I tried to write a program anyway. What is meant to happen is that the turtle is supposed to dig a 2x2 tunnel for 100 blocks, then place a chest (in slot 1 of the turtle) down and empty all of the loot into the chest. Here's the program:

function there()
  for i=1,10,1 do
        turtle.dig()
        turtle.forward()
        turtle.digUp()
  end
end

function mineBack()
  for i=1,99,1 do
        turtle.dig()
        turtle.forward()
        turtle.digUp()
  end
end

function back()
  if true then
        turtle.turnLeft()
        turtle.dig()
        turtle.forward()
        turtle.digUp()
        turtle.turnRight()
        if true do
          mineBack()
        end
  end
end

while turtle.getItemCount(1) > 0 do
  there()
  back()
  turtle.dig()
  turtle.select(1)
  turtle.forward()
  turtle.digUp()
  turtle.back()
  turtle.place()
  for i=2,16,1 do
        turtle.drop()
  end
  turtle.turnRight()
  for i=1,3,1 do
        turtle.dig()
        turtle.forward() --#This is line 45
        turtle.digUp()
  end
  turtle.turnRight()
end
The problem it's giving me is: bios:337: [string "Mine"]:45:'=' expected
This is a weird problem, because line 45 is: turtle.digUp(). I haven't managed to find any other problems because I don't
know how to fix this one.
If anyone can see a problem in my code, either by looking at it on this post, or opening it in a turtle and figuring out the problem, please respond with a suggestion or a new code to do the same thing I want done.
Thanks in advance! WRKAQARG, away!
Edited by
Lyqyd #2
Posted 16 September 2013 - 10:51 AM
Did you copy and paste this or retype it by hand?
campicus #3
Posted 16 September 2013 - 11:45 AM
Check out 'for loops' on the wiki.


for i = 1,5 do --do something 5 times
	<code>
end

Also have a look at 'while loops':


while true do
	<code>
end
LBPHacker #4
Posted 16 September 2013 - 11:49 AM
-snip-
You should check those out too. Nothing's wrong with his for loops. The problem is on line 24 where he used 'do' instead of 'then'.
Lyqyd #5
Posted 16 September 2013 - 12:35 PM
Line 24 would throw a 'then' expected, which leads me to suspect that this is retyped and that OP added parentheses to the function call on line 44 that aren't in the original code.
campicus #6
Posted 17 September 2013 - 10:05 AM
-snip-
You should check those out too. Nothing's wrong with his for loops. The problem is on line 24 where he used 'do' instead of 'then'.

I stand corrected! I forgot all about being able to define the increments in for loops. Still, the 1 isn't need in those for loops.

I'm not sure I understand this:

if true then
  do something
end

Wouldn't that code always 'do something'?
LBPHacker #7
Posted 17 September 2013 - 10:12 AM
-snip-
Debugging? And yeah, the 1 isn't needed; I just didn't like the way you indirectly stated that that was the problem.
campicus #8
Posted 17 September 2013 - 10:15 AM
-snip-
Debugging? And yeah, the 1 isn't needed; I just didn't like the way you indirectly stated that that was the problem.

Debugging what? I don't understand sorry :s I just wanted to know the purpose of "if true then"
And yep, I was definitely wrong about the for loops, my bad.