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

Turtle-related question

Started by Datashocker, 05 March 2012 - 05:06 AM
Datashocker #1
Posted 05 March 2012 - 06:06 AM
I'm new to Lua (coding in general, actually), so please excuse me if there's a really obvious solution to this.
Now, I've written a program on my turtle that as far as I know should dig me a custom bunker area. Code is below (It's not very readble right now, I'm sorry about that. I usually don't pretty it up untill I know it works):

x = 0
while true do
turtle.down(1)
turtle.digDown()
x = x+1
if x == 8 then
break
end
end
x = 0
while true do
turtle.dig()
turtle.up(1)
turtle.dig()
turtle.forward(1)
turtle.down(1)
x = x+1
if x == 3 then
break
end
end
turtle.turnLeft(1)
x = 0
while true do
turtle.dig()
turtle.up(1)
turtle.dig
turtle.forward(1)
turtle.down()
x = x+1
if x == 3 then
break
end
end
x = 0
turtle.turnRight(2)
turtle.forward(3)
while true do
turtle.dig()
turtle.up(1)
turtle.dig()
turtle.down(1)
turtle.forward(1)
x = x+1
if x == 3 then
break
end
end
y = 0
while true do
turtle.turnLeft(1)
turtle.dig()
turtle.up(1)
turtle.dig()
turtle.forward(1)
turtle.turnLeft(1)
turtle.down(1)
x = 0
while true do
turtle.dig()
turtle.up(1)
turtle.dig()
turtle.forward(1)
turtle.down(1)
x = x+1
if x == 6 then
break
end
end
turtle.turnRight(1)
turtle.dig()
turtle.up(1)
turtle.dig()
turtle.forward(1)
turtle.turnRight(1)
turtle.down(1)
x = 0
while true do
turtle.dig()
turtle.up(1)
turtle.dig()
turtle.forward(1)
turtle.down(1)
x = x+1
if x == 6 then
break
end
end
y = y+1
if y == 4 then
break
end
end

However, when I try to run the program it errors, giving me:
bios:206: [string "bunkertest"]:28: '=' expected

The only thing on Line28 is below, so I'm not sure why it's expecting an '='
turtle.forward(1)


Any help would be appreciated.
Espen #2
Posted 05 March 2012 - 06:48 AM
You can't pass any arguments to the turtle-movement functions.
You have to call them multiple times (for-loop) in order to move multiple times.
Hint: Make a separate function for this which takes an argument for the desired movement and one for the number of how many times said movement is to be performed.
Datashocker #3
Posted 05 March 2012 - 07:29 AM
Ah, that makes sense. I'll have to rewrite it then.
Thanks, Espen.
Sebra #4
Posted 12 March 2012 - 06:24 PM
However, when I try to run the program it errors, giving me:
bios:206: [string "bunkertest"]:28: '=' expected
The only thing on Line28 is below, so I'm not sure why it's expecting an '='
turtle.forward(1)
turtle.dig without "()" on the previous line