r/ComputerCraft • • Jan 31 '21

<'eof'> error need help

Im building a program where i can control my IC2 reactor and itll output information to monitors currently I'm trying to get it to just start the reactor but im getting an end of file error and im new to Lua and i can't quite figure out what is causing this any help is appreciated here is my Pastebin

1 Upvotes

6 comments sorted by

2

u/SadieWopen Feb 01 '21 edited Feb 01 '21

Line 29, 35 and 42 are your problems. on line 26 you start an 'if' block, line 29 you 'end' it and line 31 you 'else if' it, which doesn't work. I think elseif is meant to be one word too.

1

u/Drunkmonkey1186 Feb 01 '21

ok that may be my problem i had removed those end's before after looking up how if statements were used but i did not change my else if's

2

u/SadieWopen Feb 01 '21

The other problem is that most of this code won't do anything. I would suggest trying these things out in the console of the computer, line by line, so you can see what they do (this is a great way to check your understanding of the language.

1

u/SadieWopen Feb 01 '21

Actually, there are quite a few problems. I'm gonna tidy it up for you so you can compare.

1

u/SadieWopen Feb 01 '21

https://pastebin.com/Y7XBnXYs

Here is what I came up with. Notable changes from your version. Peripheral wraps give you access to the functions that the peripheral offers, you need to assign them to a variable.

Although you had your check for correct password in the code, it was never going to count up to 3 because that block of code only ran once.

I added a temperature check into the monitor loop so that the computer can actually react to an overheating situation. Before it would only not turn on if the temperature was too high. Now, not only will it turn the reactor off when the temperature gets up there, but when it comes down again it will turn it back on.

1

u/Drunkmonkey1186 Feb 01 '21

i understood i had some logic errors i needed to clean up still new to lua didnt realize functions needed to be placed before there called not only that but i made assumptions on how certain things worked (coming from C# and javascript) and they were incorrect thanks for the help!