Jump to content




File error for No reason whatsoever


  • You cannot reply to this topic
5 replies to this topic

#1 Mendax

  • Members
  • 366 posts

Posted 07 December 2012 - 08:40 PM

Now, I have a rather large amount of code (more than your average doorlock) and it is erroring in file.readLine(). file is defined and there is a file.close() line.
The error is:
:54: attempt to index ? (a nil value)
Here is my code.
Spoiler
EDIT:
And the problem was: fs.open can't tell where you are. Just me not knowing something.

#2 faubiguy

  • Members
  • 213 posts

Posted 07 December 2012 - 08:53 PM

Attempt to index nil on a file means that the file failed to open, usually becuase it doesn't exist (or the directory doesn't exist when writing to a file).

You can check if fs.open returns nil and do something else if it does.

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 07 December 2012 - 08:53 PM

What argument are you starting this program with, and if it's a valid path to a file, what is the full path of the file and what are the contents?

#4 Mendax

  • Members
  • 366 posts

Posted 07 December 2012 - 08:55 PM

Solved it with help from kaz on IRC.

#5 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 07 December 2012 - 08:57 PM

Please post what the issue ended up being caused by and the solution, so that others searching for help with a similar problem might have their question answered if they find this post.

#6 Mendax

  • Members
  • 366 posts

Posted 07 December 2012 - 10:05 PM

Ok, edited the OP.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users