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

[lua] [Error] [Turtle]

Started by zerozapper, 10 December 2012 - 11:55 AM
zerozapper #1
Posted 10 December 2012 - 12:55 PM
Hello,
(i just noticed that i did not give this a title, Whoops)
I'm trying to write a basic code to build a house. I'm new to programming (I have a little experience with php).

this is what i have so far:


x = "1"
i = "9"

while x<=i do
if turtle.detectDown() then
turtle.digDown()
else turtle.placeDown()
turtle.forward()
x = x + 1


end
end

but when i run this the turtle only digs/places and moves forward once and gives this error message:

Build:4: attempt to compare string with number expected, got string

I can't figure out whats wrong.
To my understanding it should keep doing the commands until X is more than 9 (i)


Thanks in advance,
Zerozapper
Kingdaro #2
Posted 10 December 2012 - 01:03 PM
Remove the quotes around 1 and 9 at the beginning of your script.
zerozapper #3
Posted 10 December 2012 - 01:09 PM
Thanks for the quick reply!

That worked, i can't believe it was something that simple…. Thanks!