6 posts
Posted 22 October 2012 - 07:15 PM
http://pastebin.com/eQy1FZf1Link to the pastebin, I get an error on line 38, saying end expected for while, even though I don't want the while ending at line 38? Any ideas? I'm new to Lua, so it's probably just operator error, but no amount of googling has helped so far. Here's exactly what you see when you run the code as it sits:
http://imgur.com/NqiMsIf anyone has any ideas, or knows what the problem is, it would be greatly appreciated!
2217 posts
Location
3232235883
Posted 22 October 2012 - 07:21 PM
too many ends
136 posts
Posted 22 October 2012 - 07:22 PM
You don't need an end for each elseif
Should be simlar to:
if <expression> then
<block>
elseif <expression> then
<block>
end
136 posts
Posted 22 October 2012 - 07:23 PM
you dont put end before elseifs
Beat me to it…
Also lines 15 and 25 I believe.
6 posts
Posted 22 October 2012 - 07:23 PM
The ends are there for the for loops, not the elseifs? Or do I not need one for the for loops?
2217 posts
Location
3232235883
Posted 22 October 2012 - 07:25 PM
turtle receive:
rednet.open("right")
while true do
event, id, text = os.pullEvent()
if event == "rednet_message" then
if text == "excavate" then
shell.run(""..text, "5")
elseif text == "go up" then
for x = 0, 5 do
if turtle.detectUp() then
turtle.digUp()
x=x+1
end
turtle.up()
end
end
elseif text == "go right" then
turtle.turnRight()
for x = 0, 5 do
if turtle.detect() then
turtle.dig()
end
turtle.forward()
x=x+1
end
turtle.turnLeft()
elseif text == "go left" then
turtle.turnLeft()
for x = 0, 5 do
if turtle.detect() then
turtle.dig()
end
turtle.forward()
x=x+1
end
turtle.turnRight()
elseif text == "go down" then
for x = 0, 5 do
if turtle.detectDown() then
turtle.digDown()
end
turtle.down()
x=x+1
end
elseif text == "go back" then
turtle.turnRight()
turtle.turnRight()
for x = 0, 5 do
if turtle.detect() then
turtle.dig()
end
turtle.forward()
x=x+1
end
turtle.turnLeft()
turtle.turnLeft()
end
end
136 posts
Posted 22 October 2012 - 07:26 PM
The ends are there for the for loops, not the elseifs? Or do I not need one for the for loops?
You have 'end's instead of 'else's :3
21, 32, 42, 53
6 posts
Posted 22 October 2012 - 07:34 PM
Ah, I see what you mean now, thanks for the assist!
136 posts
Posted 22 October 2012 - 07:36 PM
Good job super-team