This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
mistamadd001's profile picture

end expected to close... cant find problem area

Started by mistamadd001, 03 June 2014 - 12:26 PM
mistamadd001 #1
Posted 03 June 2014 - 02:26 PM
Hi all,

Sorry for the vague description but I've been looking at my code for about 30 mins trying to figure out which statement hasnt been completed correctly, however the line the error is pointing to is the start of an internal function to check for a button click.

My code

If you can let me know what I'm doing wrong I would really appreciate it.

Cheers,
MistaMadd001
theoriginalbit #2
Posted 03 June 2014 - 02:30 PM
For the future please post error messages, they're very useful!

as for the problem take a look at lines 76 — 78
mistamadd001 #3
Posted 03 June 2014 - 02:37 PM
the error is not with the while loop, I realise there is nothing going on there yet as I am having a problem with the function it is trying to call, the exact error I'm getting is :53: 'end' expected (to close 'function' at line 15)

as you can see line 53 is the start of my button.clicked() nested function, and therefore should not be closing the parent function: Button().

NB/ FTB Ultimate pack is the platform being used
mistamadd001 #4
Posted 03 June 2014 - 02:49 PM
I have moved the button.clicked() function above the button.draw() function and that has seemed to fix it, I think I'm correct in assuming that the return button was in effect ending the parent function and therefore no further nested functions could be created.

in other news, the click does nothing <_</>, I've clicked several places and the loop does not end like its designed to. grrrr
Whitecatblack #5
Posted 03 June 2014 - 02:49 PM
mistamadd001 said:
-snip-
Hmmm…it may be the fact that this line is in there on line 51:

return button
The computer wants to end the function after a return, so the fact that there were more things after it within the function drew an error.

[Edit] Sniped

Whitecatblack
Edited on 03 June 2014 - 12:50 PM
theoriginalbit #6
Posted 03 June 2014 - 03:01 PM
the error is not with the while loop, I realise there is nothing going on there yet as I am having a problem with the function it is trying to call, the exact error I'm getting is :53: 'end' expected (to close 'function' at line 15)
and this is why posting the error message is important, I saw the 3 errors in the while loop, but missed the one that caused this error message (which Whitecatblack's reply addresses)
Goof #7
Posted 03 June 2014 - 05:53 PM
the error is not with the while loop, I realise there is nothing going on there yet as I am having a problem with the function it is trying to call, the exact error I'm getting is :53: 'end' expected (to close 'function' at line 15)
and this is why posting the error message is important, I saw the 3 errors in the while loop, but missed the one that caused this error message (which Whitecatblack's reply addresses)
TheOriginalBIT is actually telling you very important information.

Before any of us is able to help fully, you need to post what the error actually is.

On Topic:
I made everything in your code work… ( no errors so far ).

And just keep in mind:
All statements in Lua, needs to be OPENED. then ALWAYS needs to be closed again with "end" or "until"
At line 76 - 78 you have several issues, where you either forget to open,
or close the loop/function

http://pastebin.com/pGnG06fu EDIT: Somehow the full code didn't get saved properly… Just Pasted the new one (Works)

I commented out the things I changed in your code.

Sorry for the quick explanation, but im in a bit of hurry.


I'll edit this if i get time.

I hope i could help
Edited on 03 June 2014 - 04:18 PM