[Error] [lua] Eof expected?
#1
Posted 14 June 2012 - 07:22 AM
Eof expected? Right so end of function. So it's saying there needs to be an end to my function? But there is one?
E.g. (wrote this simple as hell program to demonstrate what I'm talking about)
Btw I'm still not sure how to colour the text and put it in that box so its easier to read like everyone else so I'm just gonna have to put a wall of text :L.
func = shaft()
if turtle.detectdown(7)
then
end
ekse
turtle.digdown()
shaft()
end
So I know that the problem is with my ends. Also, I really would prefer being shown how to do ends properly rather than just being corrected Thanks in advance!
#2
Posted 14 June 2012 - 08:06 AM
Question
do you edit in CC or outside of it with some other IDE / text editor ?? I personally use notepad++
#3
Posted 14 June 2012 - 11:35 AM
and iirc it was case senstiive so digDown not digdown
besides that script does not make sense?
Looks like you're trying recursion, might be better to use a loop though
#4
Posted 14 June 2012 - 11:57 AM
Pinkishu, on 14 June 2012 - 11:35 AM, said:
and iirc it was case senstiive so digDown not digdown
besides that script does not make sense?
Looks like you're trying recursion, might be better to use a loop though
deity12, on 14 June 2012 - 07:22 AM, said:
[EDIT]
--response to bellow post--
thank you Pinkishu for reminding me I accidentally confused EOF with END error's
[/EDIT]
#5
Posted 14 June 2012 - 01:33 PM
detectDown(7) doesn't make much sense to me either or is it of any use to put the 7 there?
lets use "scope levels"
func = shaft() -- Scope Level 0 if turtle.detectdown(7) -- Scope Level 0 then -- Scope Level 0->1 end -- Scope Level 1->0 ekse -- fail (lets assume its else) Scope Level 0->1 (notice, theres no if to even link up to since it ended there ^) turtle.digdown() -- Scope Level 1 shaft() -- Scope Level 1 end - Scope Level 0
So it expects EOF instead of an else since there no if to link it too since it ended the line before
#6
Posted 14 June 2012 - 04:48 PM
function <FunctionName>() -- code end -- or <FunctionName> = function() -- code end
#7
Posted 14 June 2012 - 04:56 PM
MysticT, on 14 June 2012 - 04:48 PM, said:
function <FunctionName>() -- code end -- or <FunctionName> = function() -- code end
No one is reading the above text. it is Pseudo code that does nothing. To fix the problem he would need to post his ACTUAL CODE.
#8
Posted 14 June 2012 - 05:02 PM
BigSHinyToys, on 14 June 2012 - 04:56 PM, said:
MysticT, on 14 June 2012 - 04:48 PM, said:
function <FunctionName>() -- code end -- or <FunctionName> = function() -- code end
No one is reading the above text. it is Pseudo code that does nothing. To fix the problem he would need to post his ACTUAL CODE.
deity12, on 14 June 2012 - 07:22 AM, said:
deity12, on 14 June 2012 - 07:22 AM, said:
But yes, he has to post the actual code so we can see the error.
#9
Posted 14 June 2012 - 05:09 PM
the code he posted is a example of a problem cant be fixed from the example code he posted. the func is just lazy doing it in a pseudo way in a demonstration. I would put money on it that in his code he uses the correct "function = exampleName()" syntax
#10
Posted 14 June 2012 - 05:19 PM
BigSHinyToys, on 14 June 2012 - 05:09 PM, said:
func = shaft() -- attempt to call nil if turtle.detectdown(7) then end ekse -- = expected (or something else) turtle.digdown() -- attempt to call nil shaft() -- attempt to call nil end -- EOF ExpectedThe first errors don't matter, since they would never get executed, but the "eof expected" is there.
#11
Posted 14 June 2012 - 05:28 PM
pseudo code is not designed to be executed but for ruffing out a programs flow of command's allowing for change in design before a single real section of code is ever typed. his code is ether a total fail or pseudo code (where func represents a function call and shaft() represents a function that would be called that digs or interacts with a shaft of some kind.)
#12
Posted 14 June 2012 - 05:37 PM
try it />
#13
Posted 14 June 2012 - 05:37 PM
#14
Posted 14 June 2012 - 05:40 PM
#15
Posted 14 June 2012 - 05:49 PM
Pinkishu, on 14 June 2012 - 05:40 PM, said:
I wasn't originally replying to you, by the way. You snuck that post in whilst I was typing!
That bit of code up there has deeper issues than a typo'd else or a broken function declaration. It lacks understanding of if structures, for one thing.
I'd bet the EOF error is more related to the overuse of ends inside ifs than anything else (despite the fact that this one would match up fine if the function declaration was valid). I assume there are enough mismatched ifs and not enough missing ends elsewhere so that we are reaching an end after the closing end.
#16
Posted 14 June 2012 - 05:51 PM
#17
Posted 14 June 2012 - 05:51 PM
if then end else will never work /> unless there was another if above it maybe
#19
Posted 15 June 2012 - 03:25 AM
Firstly, the reason i typed that instead of my actual code id that I get that sort of error with a lot of things i try to code. If somebody just corrects my code, that only fixes one problem, and one code. What i was really asking for was how do I use 'end' properly. It's a real killer for any coding I attempt. And yes, agreed the code I posted was complete crap, I know that and I have made much better codes, but the best I can do is sustitute from someone else's code because i can't change some things because of 'eof expected'. Basically I would like to either be taught when and how 'end' should be used or pointed to somewhere that can show me how. And yes, I was just being lazy there and typo'd/typed incorrect synatx. I ahve tried many, many different ways of arranging my ends but none seem to work.
#20
Posted 15 June 2012 - 09:18 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users