Reputation: 27
I'm a beginner at LUA so I'm having some trouble with it. I'm using the code for a Minecraft mod called Computercraft, but to me it's a great introduction to programming.
I've been searching the web to find out why my code of not even 26 lines is failing, but I couldn't find it sadly.
Here's the code:
monitor = peripheral.wrap("right")
monitor.clear()
monitor.setCursorPos(1,1)
monitor.setTextScale(1)
monitor.print("Current mode:")
monitor.setCursorPos(1,3)
monitor.print("Dust gaat naar furnace")
redstone.setOutput(back,false)
print("Dust gaat automatisch naar de furnace toe")
print("Wil je dat de dust naar de chest gaat in plaats van de furnace?")
write()
while input == ja
do
print("Oke :)")
redstone.setOutput(back,true)
monitor.clear()
monitor.setCursorPos(1,1)
monitor.print("Current mode:")
monitor.setCursorPos(1,3)
monitor.print("Dust gaat naar chest")
end
else
print("Okeuu dan niet jongee")
end
I know that I have used 'end' 2 times. This is because I get an error when I remove one.
The error I get when I run the program is:
bios:14: [string ".temp"]:22: '<eof>' expected.
The error I get when I remove the first 'end'.
The error I get when I remove the second 'end'.
EDIT Okay well after some advice i managed to get rid of the error. Thanks to all the people that responded! c: Now i got an other error though lol. As suggested i made a new post about it: Basic LUA problems
Upvotes: 2
Views: 516
Reputation: 66
The :22: is telling you that the error has occurred around line 22 of the script, which is the else. If you have a look at the Lua reference guide you will see that else belongs with an if statement, not a while statement.
Your code should probably be as follows, as a while doesn't make sense here
if input == ja
then
... code ...
else
... other code ...
end
Upvotes: 2