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

While help?

Started by Borka223, 24 April 2012 - 10:02 AM
Borka223 #1
Posted 24 April 2012 - 12:02 PM
Hello world! I could use some help here, so every reply is appreciated!
I am writing a turtle program, but it shows

bios:206: [string "mine"]:9: 'do' expected the code looks like this:

x = 0
y = 0
a = 0
b = turtle.compare
turtle
.dig()
turtle.forward()
x = x+1
while turtle.getitemcount<64 do
while turtle.compare() = d do
turtle.dig()
turtle.forward()
x = x+1
end
end
:)/>/>
Help?
Xtansia #2
Posted 24 April 2012 - 01:36 PM
Your forgetting the parenthesis ie. ()'s
On some of your calls to functions,
Like line 4 where you don't have () after turtle.compare,
Also line 8:

while turtle.getitemcount<64 do
--Should Be:
while turtle.getItemCount(SlotNumberHere) < 64 do
Line 9:

while turtle.compare() = d do
--Firstly the variable d is never assigned
--Secondly when comparing two variables you must use == not =
Borka223 #3
Posted 24 April 2012 - 06:55 PM
Sorry, I mistyped the code; it is

x = 0
y = 0
a = 0
b = turtle.compare()
turtle.dig
turtle.forward
x = x+1
while turtle.getitemcount(1)<64 do
while turtle.compare() = b do
  turtle.dig()
  turtle.forward()
end
end

And when I make = a ==
it says:

mine:8: attempt to call nil
Then I change
turtle.getitemcount
to
turtle.getItemCount
and it WORKS!
Thanks for your help!
Luanub #4
Posted 24 April 2012 - 09:51 PM
You will need to correct this line as well to get it to work properly.


while turtle.compare() = b do
to 

while turtle.compare() == b do

= syntax is to set a var =, to check it == so

a = 1

if a == 1 then do stuff end