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

Bios <name> error

Started by Ninjawolf0007, 06 December 2013 - 06:40 PM
Ninjawolf0007 #1
Posted 06 December 2013 - 07:40 PM
Would anyone mind helping me with this one? I can't seem to figure it out. I'm running forge 9.11.x with CC 1.57 if that helps.
I keep getting a bios error, a '=' error or a do on line 2 error….

x = 0
for x, 16 do
  turtle.forward()
  turtle.turnRight()
  turtle.place()
  turtle.turnLeft()
  x + 1
  y + 1
   if y == 16 then
	turtle.place()
	turtle.turnLeft()
	x = 0
	y = 0
   end
end
Edited on 06 December 2013 - 06:53 PM
Lyqyd #2
Posted 06 December 2013 - 07:55 PM
The problem is the two lines here:


x + 1
y + 1

You don't need to add one to x at all, since the for loop does that. You need to tell Lua where to put the value of the addition operation though. Since you can't change the value of x inside the loop (it will always be the next value when the loop iterates), your (corrected) code is equivalent to this:


for x=1, 16 do
    turtle.forward()
    turtle.turnRight()
    turtle.place()
    turtle.turnLeft()
end
turtle.place()
turtle.turnLeft()

What are you actually trying to do?
Ninjawolf0007 #3
Posted 06 December 2013 - 08:00 PM
The problem is the two lines here:


x + 1
y + 1

You don't need to add one to x at all, since the for loop does that. You need to tell Lua where to put the value of the addition operation though. Since you can't change the value of x inside the loop (it will always be the next value when the loop iterates), your (corrected) code is equivalent to this:


for x=1, 16 do
	turtle.forward()
	turtle.turnRight()
	turtle.place()
	turtle.turnLeft()
end
turtle.place()
turtle.turnLeft()

What are you actually trying to do?

Thank you.

I am working on an automatic way to have turtles, placed, activated, and given directions to go to, so they can mine out the world, make more turtles, etc… The standard replication challenge.

Still getting an expected do on line 2 error.
Edited on 06 December 2013 - 07:01 PM
TheOddByte #4
Posted 06 December 2013 - 08:47 PM
Well then you must have forgotten the 'do'
And post your current code that is erroring.

There is 3 parameters for the for loop, The starting value, the finishing value and finally the increment/decrement value.

for i = <starting value>, <finishing value>, <increment/decrement value> do
  -- Code
end
Ninjawolf0007 #5
Posted 06 December 2013 - 09:33 PM
Well then you must have forgotten the 'do'
And post your current code that is erroring.

There is 3 parameters for the for loop, The starting value, the finishing value and finally the increment/decrement value.

for i = <starting value>, <finishing value>, <increment/decrement value> do
  -- Code
end

"for x=1, 16 do" <– "do" is right there. If the increment/decrement value isn't put in it defaults to 1
Bomb Bloke #6
Posted 07 December 2013 - 08:01 AM
It's right there in Lyqyd's code, yes. But unlike his code, the "for" loop you constructed in your first post is not a valid one, and I'm willing to bet that your current script isn't an exact match to what he gave you.

Please post the rest of that script.
TheOddByte #7
Posted 07 December 2013 - 09:19 AM
If you are using the exact code that Lyqyd posted then it shouldn't give any errors, Do as Bomb Bloke suggested and post your current code.