You should use the code blocks to preserve code formatting when posting your code, it makes it a lot easier to read. The problem with your code is you are missing and "end" at the end. In lua, there are a number of calls that work as brackets. To make things easier, we use indentation to help remember where we are missing an end. Here are some examples:
function callme(parameters)
<code>
end
for i,j in ipairs(list) do
<code>
end
while <condition> do
<code>
end
if <condition> then
<code>
end
if <condition> then
<code>
elseif <condition> then
<code>
else
<code>
end
If you put any of these inside each other, each must be closed off by an end. Again, indentation helps you keep track of where you were, since you cannot go up an indentation level without using an end statement. For example:
local cool = "back"
local control = "right"
while true do
if rs.getInput(cool) then
rs.setOutput(control, true)
sleep(45)
rs.setOutput(control, false)
else
sleep(1)
end
end
You will notice that each time I go in a level, I come back out later. In your code, your function and your if statement go in one level, but you only have one end statement, so the lua interpreter hits the end of the file and is still expecting another end, and thus gives an error.
Also, that last example should be a working version of your code. Cheers!