Jump to content




Loading Tables from Files



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

#1 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 10 April 2014 - 01:44 AM

This page (http://computercraft...Tables_to_Files) is incorrect, at least in CC1.6. It states this line:
local data = file.readAll()
which gives me a 'nil' error. It should be this:
local data = file.read()
At least, as far as I know.

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 10 April 2014 - 02:08 AM

nope. readAll is fine.
I'm going to assume the error message is attempt to index ? (a nil value)
which means the file you're trying to read doesn't exist.

#3 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 11 April 2014 - 08:21 PM

One of the things I found out with CC1.6+ If you try the following:
local file = fs.open("data", "r")
local file = file.readAll()
Will error saying attempt to index global and moan at you!

If you take away the local bit so it looks like this:
file = fs.open("data", "r")
file = file.readAll()

It should work! Well it did when I just tested it!

#4 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 11 April 2014 - 08:33 PM

View PostDannySMc, on 11 April 2014 - 08:21 PM, said:

One of the things I found out with CC1.6+ If you try the following:
local file = fs.open("data", "r")
local file = file.readAll()
Will error saying attempt to index global and moan at you!

If you take away the local bit so it looks like this:
file = fs.open("data", "r")
file = file.readAll()

It should work! Well it did when I just tested it!
That's strange. I use 'local file = fs.open("fileName","r")' in CC1.6 without problems. Sounds like something else is going on there, DannySMc.

#5 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 12 April 2014 - 01:00 AM

View PostDannySMc, on 11 April 2014 - 08:21 PM, said:

One of the things I found out with CC1.6+ If you try the following:
local file = fs.open("data", "r")
local file = file.readAll()
Will error saying attempt to index global and moan at you!

If you take away the local bit so it looks like this:
file = fs.open("data", "r")
file = file.readAll()

It should work! Well it did when I just tested it!
yeh as Dog said, you've definitely got something wrong somewhere else, removing local is never a solution, and the first code — although it has a redundant `local` — works perfectly fine.
local file = fs.open("data", 'r')
file = file.readAll() --# its still local here, 'cause you defined it local above


#6 Dahknee

  • Members
  • 1,808 posts
  • Location/home/da

Posted 12 April 2014 - 03:30 PM

View Posttheoriginalbit, on 12 April 2014 - 01:00 AM, said:

View PostDannySMc, on 11 April 2014 - 08:21 PM, said:

One of the things I found out with CC1.6+ If you try the following:
local file = fs.open("data", "r")
local file = file.readAll()
Will error saying attempt to index global and moan at you!

If you take away the local bit so it looks like this:
file = fs.open("data", "r")
file = file.readAll()

It should work! Well it did when I just tested it!
yeh as Dog said, you've definitely got something wrong somewhere else, removing local is never a solution, and the first code — although it has a redundant `local` — works perfectly fine.
local file = fs.open("data", 'r')
file = file.readAll() --# its still local here, 'cause you defined it local above

Ahh fair enough, I have no idea then >.<





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users