Posted 14 December 2012 - 07:16 AM
I'm very new to Lua, and am having trouble getting my mining turtle program to work. I wrote it to mine out a 2 block high space, of a size specified by the user. But when I run the program, I get an error "bios:338: [string "rect"]:37: '=' expected". Why does it tell me this? I have an '=' on that line! I had this problem before with another program I wrote where it told me " 'do' expected" when I already had one. What's going on?
Here's the code (I know the logic is somewhat convoluted, but that will be subject to later revision):
Here's the code (I know the logic is somewhat convoluted, but that will be subject to later revision):
--Variables
print("Left?")
local left = io.read()
print("Right?")
local right = io.read()
print("Forward?")
local front = io.read()
print("Backward?")
local back = io.read()
print("Up?")
local up =io.read()
print("Down?")
local down = io.read()
--Mining
turtle.turnRight()
turtle.digUp()
for i = 0, right-1 do
turtle.dig()
while not turtle.forward() do
os.sleep(.25)
end
turtle.digUp()
end
turtle.turnleft()
for i = 0, front-1 do
turtle.dig()
while not turtle.forward() do
os.sleep(.25)
end
turtle.digUp()
end
turtle.turnLeft()
turtle.turnLeft()
for i = 0, front+back-1 do
turtle.dig()
while not turtle.forward() do
os.sleep(.25)
end
turtle.digUp()
end
turtle.turnRight()
x = 1
for j = 0, right+left-1 do
turtle.dig()
while not turtle.forward() do
os.sleep(.25)
end
turtle.digUp()
if ( x % 2 ) == 0 then
turtle.turnLeft()
else
turtle.turnRight()
end
for i = 0, front+back-1 do
turtle.dig()
while not turtle.forward() do
os.sleep(.25)
end
turtle.digUp()
end
x = x+1
if ( x % 2 ) == 0 then
turtle.turnLeft()
else
turtle.turnRight()
end
end