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

Line 434: attempt to index ? (a nil value) (only when it's doing files[4])

Started by mibac138, 22 April 2013 - 07:03 AM
mibac138 #1
Posted 22 April 2013 - 09:03 AM
http://pastebin.com/77k1wQdA
Please help :C
Engineer #2
Posted 22 April 2013 - 10:36 AM
Did you ever think: it might be too many?..

Really, you have 412 lines of text you want to print. Hmm…
theoriginalbit #3
Posted 22 April 2013 - 10:43 AM
your for loop is wrong

for i=0,#files do
in Lua table indexes start at 1 so it should be

for i = 1, #files do
EDIT: Nvm just saw the if i ~= 0 then, although what is the point, just make the change I suggested.
EDIT 2: Ok time for a suggestion… add this code between 433 and 434…

if not file then
  print('Here is the problem... This file: '..tostring(files[i].dir)..' could not be opened for write')
end

Really, you have 412 lines of text you want to print. Hmm…
Doesn't look like it is printing to me, looks like it is being saved to file…
Edited on 22 April 2013 - 08:52 AM
Engineer #4
Posted 22 April 2013 - 10:56 AM
Really, you have 412 lines of text you want to print. Hmm…
Doesn't look like it is printing to me, looks like it is being saved to file…

*facepalms of stupidness from myself*
*walks away slowly…*
mibac138 #5
Posted 23 April 2013 - 02:19 AM
your for loop is wrong

for i=0,#files do
in Lua table indexes start at 1 so it should be

for i = 1, #files do
EDIT: Nvm just saw the if i ~= 0 then, although what is the point, just make the change I suggested.
EDIT 2: Ok time for a suggestion… add this code between 433 and 434…

if not file then
  print('Here is the problem... This file: '..tostring(files[i].dir)..' could not be opened for write')
end

Really, you have 412 lines of text you want to print. Hmm…
Doesn't look like it is printing to me, looks like it is being saved to file…

Ok, but what should i do now? I don't know how to repair it :C
theoriginalbit #6
Posted 23 April 2013 - 02:26 AM
Ok, but what should i do now? I don't know how to repair it :C
Well whichever file it was that couldn't be opened try different name or location, there has to be a reason why it cannot be created.
mibac138 #7
Posted 23 April 2013 - 02:34 AM
Well whichever file it was that couldn't be opened try different name or location, there has to be a reason why it cannot be created.

Ok, I tested it and saved the API to file "testing" and it's works but how can I fix that I can't save it to ".main/.apis/.OS"? :huh:/>
theoriginalbit #8
Posted 23 April 2013 - 02:37 AM
create the folders '.main' and '.apis' first. I'd assume thats what the problem is, the directories don't exist.
mibac138 #9
Posted 23 April 2013 - 02:39 AM
They exists (they are created by "Step 1 (i=0))! and this is the problem :(/>
theoriginalbit #10
Posted 23 April 2013 - 02:51 AM
try making them with fs.makeDir instead of the shell.run

short of that, I'm not too sure, I'll investigate some more

EDIT: ok this is the problem ".main/.programs/.apis/.OS" there is not .apis folder in the .programs folder
Edited on 23 April 2013 - 12:55 AM
mibac138 #11
Posted 23 April 2013 - 02:59 AM
try making them with fs.makeDir instead of the shell.run

short of that, I'm not too sure, I'll investigate some more

EDIT: ok this is the problem ".main/.programs/.apis/.OS" there is not .apis folder in the .programs folder

Oh, thank you very much! It's should be ".main/.apis/.OS" instead of ".main/.programs/.apis/.OS" really thank you very much! ^_^/>