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

[Turtle]Whats wrong with my code?

Started by Slev7n, 11 April 2012 - 08:40 PM
Slev7n #1
Posted 11 April 2012 - 10:40 PM
Hi,
this is my first try to program a turtle. The turtle should built a house without roof. x,y,z are width, length and height.
When i try to run this i get this error: bios:206: [String "house"]:36: "=" expected


x=5
y=4
z=3
turtle.select(1)
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.turnRight()

for var1=1,z,1 do
for var2=1,x,1 do
  if turtle.compare()== false then
   turtle.dig()
   turtle.place()
  end

  turtle.turnLeft()
  turtle.forward()
  turtle.turnRight()
  end

turtle.forward()
turtle.turnRight()

for var3=1,y,1 do
  if turtle.compare()== false then
   turtle.dig()
   turtle.place()
  end

  turtle.turnLeft()
  turtle.forward()
  turtle.turnRight()
  end

turtle.forward()
turtle.turnRight()

end

I really dont know whats wrong. Plz tell me if you find a mistake.
Thank you.
Edited on 12 April 2012 - 06:50 AM
Luanub #2
Posted 11 April 2012 - 10:42 PM
Your missing an end, from the looks of it for the first for loop. Probably needs to go in at line 25

Nevermind that looks good, I'm looking.

Your missing ()'s after a couple turtle.turnRight()'s
Slev7n #3
Posted 12 April 2012 - 08:23 AM
thank you now it works. I have another question. Is it possible to check the number of items in a slot every time? So that when he runs out of items he switchs to the next slot?
Glotz659 #4
Posted 12 April 2012 - 11:07 AM
You could use

turtle.getItemCount(slot)
for example:

slot = 1
if turtle.getItemCount(slot) == 0 then
slot = slot+1
turtle.select(slot)
end
Slev7n #5
Posted 12 April 2012 - 11:10 AM
thank you. I solved the problem with a function.