3 posts
Posted 06 March 2013 - 01:28 AM
Title: [LUA] [ERROR] Function wants extra 'ends'?
I've got a function (1 'end') a while loop (2 'end's) and an if/then series (3 'end's), but I keep getting this error:
… 'end' expected (to close function at line 11)
pastebin'd code here:
http://pastebin.com/TVareb3Xadding the extra 'end' makes the error stop, but for the life of me I just don't get the logic behind it. Is it a Lua thing or have I missed something?
EDIT:
I missed whitespace. 'else if' apparently isn't the correct syntax in Lua.
Edited on 06 March 2013 - 12:34 AM
3790 posts
Location
Lincoln, Nebraska
Posted 06 March 2013 - 02:10 AM
Split to new topic.
Your 'else if' statement should be 'elseif'
It should be one word.
3 posts
Posted 06 March 2013 - 03:05 AM
Split to new topic.
Your 'else if' statement should be 'elseif'
It should be one word.
I threw out and restarted this thing several times last night, and six minutes after adding the post I finally got it. Go figure.
I should have specifically stated in the edit that I did find out 'elseif' was the right syntax, I was kinda vague there. Sorry.
645 posts
Location
'Merica
Posted 06 March 2013 - 03:46 AM
I know I'm not a "Pro" but you forgot to end this
else if slot == 16 then
error("Out of materials")
else
3790 posts
Location
Lincoln, Nebraska
Posted 06 March 2013 - 04:12 AM
I know I'm not a "Pro" but you forgot to end this
else if slot == 16 then
error("Out of materials")
else
that's the elseif we were talking about…
645 posts
Location
'Merica
Posted 06 March 2013 - 12:13 PM
I know I'm not a "Pro" but you forgot to end this
else if slot == 16 then
error("Out of materials")
else
that's the elseif we were talking about…
Oh lol, I didn't care to read what you guys were talking about, oh and Congratz on mod Cranium (We used to be on a server together, and did a couple of building projects)
8543 posts
Posted 06 March 2013 - 12:40 PM
Don't post "answers" without reading the rest of the replies.
11 posts
Posted 06 March 2013 - 12:40 PM
Hi guys i have a similar problem with my program Its made to control the doors in my house depending on user input
Its meant to run a door program when you type in the correct phrase but at the moment nothing happens it just refreshes :(/>
while true do
term.clear()
term.setCursorPos(1,1)
write("Enter Door/Room: ")
input = read()
if input == "front door open" then
shell.run("fndon")
if input == "front door close" then
shell.run("fndoff")
if input == "games room open" then
shell.run("grmon")
if input == "games room close" then
shell.run("grmoff")
if input == "brads room open" then
shell.run("brmon")
if input == "brads room close" then
shell.run("brmoff")
if input == "madis room open" then
shell.run("scron")
if input == "madis room close" then
shell.run("scroof")
if input == "richs room open" then
shell.run("rrmon")
if input == "richs room close" then
shell.run("rrmoff")
else
write("error")
end
end
end
end
end
end
end
end
end
end
end
8543 posts
Posted 06 March 2013 - 12:42 PM
Every if but the first if should be `elseif` instead. Remove all but two of the `end`s.
11 posts
Posted 06 March 2013 - 12:48 PM
Thanks its working now i totally forgot about "elseif"
Thanks a billion!!